ack/lang/m2/libm2/random.mod

20 lines
335 B
Modula-2
Raw Normal View History

1987-05-13 14:36:45 +00:00
IMPLEMENTATION MODULE random;
VAR seed: CARDINAL;
PROCEDURE Random(): CARDINAL;
BEGIN
seed := seed * 77 + 153;
RETURN seed;
END Random;
PROCEDURE Uniform (lwb, upb: CARDINAL): CARDINAL;
BEGIN
IF upb <= lwb THEN RETURN lwb; END;
RETURN lwb + (Random() MOD (upb - lwb + 1));
END Uniform;
BEGIN
seed := 253B;
END random.