BAP Online Manuals : Library Reference : Library by Name : random
Previous: query_msg
Next: read

6.2.100. random

returns a random value

SYNOPSIS

INCLUDE 'prolib.h'
random(X)

SYNTAX

random(Value) (i) (o)

ARGUMENTS

integer(Value) (o) random number generated
integer(Value) (i) seed of random number generator to be set

DESCRIPTION

If Value is unbound, a random integer value between 2ˆ27 - 1 and - 2ˆ27 is returned. Otherwise the seed of the random number generator is initialised with Value.
NOTE: to avoid getting the same random numbers after a system reset, you could use the time() predicate to initialise the seed.

EXAMPLE

time(T),
random(T),
for(1,10,X),
	random(R),
	write(R),nl,
	X = 10.

ERRORS

No runtime errors.

LAYERS

prolog-process, client-server, object

RELATED PREDICATES

(none)


BAP Online Manuals : Library Reference : Library by Name : random
Previous: query_msg
Next: read