protocol
Random number generator protocol.
Paulo Moura
2.4
2018/8/14
static
(no dependencies on other entities)
Returns a new random float value in the interval [0.0, 1.0[.
static
random(Random)
random(-float) – one
Returns a new random integer in the interval [Lower, Upper]. Fails if Lower or Upper are not integers or if Lower > Upper.
static
between(Lower,Upper,Random)
between(+integer,+integer,-integer) – zero_or_one
Returns a random member of a list. Fails if the list is empty.
static
member(Random,List)
member(-term,+list(term)) – zero_or_one
Returns a random member of a list and the rest of the list. Fails if the list is empty.
static
select(Random,List,Rest)
select(-term,+list(term),-list(term)) – zero_or_one
Returns a random permutation of a list.
static
permutation(List,Permutation)
permutation(+list,-list) – one
Returns a list of the given length of random integers in random order in the interval [Lower, Upper]. Fails if Length, Lower, or Upper are not integers or if Lower > Upper.
static
sequence(Length,Lower,Upper,List)
sequence(+integer,+integer,+integer,-list(integer)) – zero_or_one
Returns an ordered set of the given size of random integers in the interval [Lower, Upper]. Fails if Length, Lower, or Upper are not integers, if Lower > Upper, or if Length > Upper - Lower + 1.
static
set(Length,Lower,Upper,Set)
set(+integer,+integer,+integer,-list(integer)) – zero_or_one
Returns a new random value in the interval [Lower, Upper[. Fails if Lower > Upper. Deprecated. Use between/3 for integers.
static
random(Lower,Upper,Random)
random(+integer,+integer,-integer) – zero_or_one
random(+float,+float,-float) – zero_or_one
Returns a list of the given length of random values in random order in the interval [Lower, Upper[. Fails if Lower > Upper or if the arguments are neither integers or floats. Deprecated. Use sequence/4 for integers.
static
randseq(Length,Lower,Upper,List)
randseq(+integer,+integer,+integer,-list(integer)) – zero_or_one
randseq(+integer,+float,+float,-list(float)) – zero_or_one
Returns an ordered set of the given size of random values in the interval [Lower, Upper[. Fails if the arguments are neither integers or floats, Lower > Upper, or Length > Upper - Lower when the arguments are integers. Deprecated. Use set/4 for integers.
static
randset(Length,Lower,Upper,Set)
randset(+integer,+integer,+integer,-list(integer)) – zero_or_one
randset(+integer,+float,+float,-list(float)) – zero_or_one
Gets the current random generator seed. Seed should be regarded as an opaque ground term.
static
get_seed(Seed)
get_seed(-ground) – one
Sets the random generator seed to a given value returned by calling the get_seed/1 predicate.
static
set_seed(Seed)
set_seed(+ground) – one
Succeeds or fails with equal probability.
static
maybe – zero_or_one
Succeeds with probability Probability or fails with probability 1 - Probability. Fails if Probability is not a float or is outside the interval [0.0, 1.0].
static
maybe(Probability)
maybe(+probability) – zero_or_one
Succeeds with probability K/N where K and N are integers satisfying the equation 0 =< K =< N. Fails otherwise.
static
maybe(K,N)
maybe(+non_negative_integer,+non_negative_integer) – zero_or_one
Calls a goal or fails without calling it with equal probability. When the goal is called, it determines if this predicate succeeds once or fails.
static
maybe_call(Goal)
maybe_call(0)
maybe_call(+callable) – zero_or_one
Calls a goal or fails without calling it with probability Probability. When the goal is called, it determines if this predicate succeeds once or fails.
static
maybe_call(Probability,Goal)
maybe_call(*,0)
maybe_call(+probability,+callable) – zero_or_one
(none)
(none)