Go to the first, previous, next, last section, table of contents.
This package provides a random number generator. To load the package,
enter the query
| ?- use_module(library(random)).
random(-Number)
-
Binds Number to a random float in the interval [0.0, 1.0). Note
that 1.0 will never be generated.
random(+Lower, +Upper, -Number)
-
Binds Number to a random integer in the interval
[Lower,Upper) if Lower and Upper are integers.
Otherwise Number is bound to a random float between Lower
and Upper. Upper will never be generated.
randseq(+K, +N, -RandomSeq)
-
Generates a sequence of K unique integers chosen randomly in the
range from 1 up to N. RandomSeq is not returned in any
particular order.
randset(+K, +N, -RandomSet)
-
Generates an ordered set of K unique integers, chosen randomly
in the range from 1 up to N. The set is returned in reversed
order, with the largest element first and the smallest last.
getrand(?State)
-
Tries to unify State with the term
rand(X,Y,Z)
where
X, Y, and Z are integers describing the state of the
random generator.
setrand(rand(+X,+Y,+Z))
-
Sets the state of the random generator. X, Y, and Z
must be integers in the ranges
[1,30269)
, [1,30307)
, and
[1,30323)
, respectively.
Go to the first, previous, next, last section, table of contents.