• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

A.46 library(random): Random numbers
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(random): Random numbers
          • random/1
          • random_between/3
          • random/3
          • setrand/1
          • getrand/1
          • maybe/0
          • maybe/1
          • maybe/2
          • random_perm2/4
          • random_member/2
          • random_select/3
          • random_subseq/3
          • randset/3
          • randseq/3
          • random_permutation/2
          • random_numlist/4
    • Packages
Availability::- use_module(library(random)).(can be autoloaded)
Source[det]setrand(+State)
[det]getrand(-State)
Query/set the state of the random generator. This is intended for restarting the generator at a known state only. The predicate setrand/1 accepts an opaque term returned by getrand/1. This term may be asserted, written and read. The application may not make other assumptions about this term.

For compatibility reasons with older versions of this library, setrand/1 also accepts a term rand(A,B,C), where A, B and C are integers in the range 1..30,000. This argument is used to seed the random generator. Deprecated.

Errors
existence_error(random_state, _) is raised if the underlying infrastructure cannot fetch the random state. This is currently the case if SWI-Prolog is not compiled with the GMP library.
See also
set_random/1 and random_property/1 provide the SWI-Prolog native implementation.
ClioPatria (version V3.1.1-51-ga0b30a5)