Search                        Top                                  Index
TEACH RANDOM                                       A.Sloman October 1993

random(number) -> number
random0(number) -> number

There are several different uses of the procedure random, but the
simplest is to give it an integer N, whereupon it will return an integer
between 1 and N.

Example:

    repeat 10 times random(5) => endrepeat;

random can also be used with a decimal number

    repeat 20 times random(5.0) => endrepeat;

If you wish to get an integer between 0 and the number N, then you
can use the procedure random0, in this form:

    random0(N + 1)

for example

    repeat 10 times random0(4) => endrepeat;

or
    repeat 10 times random0(4.0) => endrepeat;

It is possible to "re-start" the behaviour of random and random0
by assigning a given integer, e.g. 0 to the variable ranseed
For more details try
HELP * RANDOM
REF  * RANDOM

--- $poplocal/local/teach/random
--- Copyright University of Birmingham 1993. All rights reserved. ------