This library is derived from the DEC10 library random. Later, the core random generator was moved to C. The current version uses the SWI-Prolog arithmetic functions to realise this library. These functions are based on the GMP library.
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.
random_subseq/3 may also be called with Subseq and Complement bound and List unbound, which will recreate List by randomly interleaving Subseq and Complement. This mode may fail randomly, matching SICStus behavior. The failure probability corresponds to the probability of the "forward" mode selecting a Subseq/Complement combination with different lengths.
?- randset(5, 5, S). S = [1, 2, 3, 4, 5]. (always) ?- randset(5, 20, S). S = [2, 7, 10, 19, 20].
randseq(K, N, List) :- randset(K, N, Set), random_permutation(Set, List).
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
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.