Download ciao Reference Manual - pdf

Transcript
Chapter 164: Random numbers
655
164 Random numbers
Author(s): Daniel Cabeza.
Version: 1.10#6 (2004/8/7, 21:46:39 CEST)
Version of last change: 1.9#275 (2004/1/9, 16:25:9 CET)
This module provides predicates for generating pseudo-random numbers
164.1 Usage and interface (random)
©
®
• Library usage:
:- use_module(library(random)).
• Exports:
− Predicates:
random/1, random/3, srandom/1.
­
ª
164.2 Documentation on exports (random)
random/1:
PREDICATE
random(Number)
Number is a (pseudo-) random number in the range [0.0,1.0]
random/3:
PREDICATE
random(Low, Up, Number)
Number is a (pseudo-) random number in the range [Low, Up]
Usage 1: random(+int, +int, -int)
− Description: If Low and Up are integers, Number is an integer.
srandom/1:
PREDICATE
srandom(Seed)
Changes the sequence of pseudo-random numbers according to Seed. The stating sequence
of numbers generated can be duplicated by calling the predicate with Seed unbound (the
sequence depends on the OS).