Logo

Programming-Idioms

History of Idiom 69 > diff from v32 to v33

Edit summary for version 33 by Frederick John:
New Erlang implementation by user [Frederick John]

Version 32

2019-01-25, 11:41:47

Version 33

2019-07-15, 18:34:11

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Code
r = :rand.uniform(n)
Comments bubble
n is an integer

results in a random number between 1-n
Doc URL
http://erlang.org/doc/man/rand.html#uniform-1