SOL_PRNG
A simple functional pseudo random number generator. No mutability. Relies on shadowing as of now.
Functions:
let r = new;
// -> true || false
r.next_bool;
// -> i32
r.next_i32;
// -> u32
r.next_u32;
// -> i64
r.next_i64;
// -> u64
r.next_u64;
// -> u32 in inclusive range (from, to)
r.next_ranged_u32;
// -> u64 in inclusive range (from, to)
r.next_ranged_u64;
Usage:
// Create an initial Rand. For non-determinism use something like the system
// time as a seed.
let r = new;
// Shadows previous Rand, creates n (holds your result).
let = r.next_i32;
println!;
// Shadows previous Rand, shadows n (holds your new result).
let = r.next_i32;
println!;
// It does not matter the type of the last generated value.
let = r.next_bool;
println!;
let = r.next_u64;
println!;
let = r.next_ranged_u32;
println!;