Logo

Programming-Idioms

History of Idiom 15 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-08-20, 11:58:43

Version 5

2015-08-20, 15:37:06

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.

Imports
import std.random;
Code
auto x1 = uniform(a, b+1);
auto x2 = uniform!"[]"(a, b);
Comments bubble
default boundaries for uniform are exclusive of upper bound, but can be configured as shown for 'x2' example.