Logo

Programming-Idioms

History of Idiom 15 > diff from v44 to v45

Edit summary for version 45 by Plecra:
New Rust implementation by user [Plecra]

Version 44

2020-04-29, 09:19:50

Version 45

2020-07-15, 15:52:02

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.

Variables
a,b
Extra Keywords
choose
Extra Keywords
choose
Imports
use rand::distributions::Uniform;
Code
Uniform::new_inclusive(a, b).sample(&mut rand::thread_rng())
Doc URL
https://docs.rs/rand/0.7.3/rand/distributions/struct.Uniform.html