Logo

Programming-Idioms

History of Idiom 15 > diff from v27 to v28

Edit summary for version 28 by :
New Lua implementation by user [jparoz]

Version 27

2015-12-30, 17:10:40

Version 28

2016-02-16, 16:14:27

Idiom #15 Pick uniformly a random integer in [a..b]

Pick a random integer greater than or equals to a, inferior or equals to b. Precondition : a < b.

Idiom #15 Pick uniformly a random integer in [a..b]

Pick a random integer greater than or equals to a, inferior or equals to b. Precondition : a < b.

Code
math.random(a, b)
Comments bubble
Be sure to do math.randomseed(os.time()) or something equivalent somewhere up above.