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.


    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;

    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

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