Fmlib_browser.Random
Generate Random Numbers
val constant : 'a -> 'a t
constant a
Generate the same value every time.
rand >>= f
Generate the random value a
using the generator rand
, and then use f a
to generate a random value b
.
map f rand
Use rand
to generate a random value and then map it by f
.
val int : int -> int t
int bound
A random generator which generates numbers n
satisfying 0 <= n < bound
.
Precondition: 0 < bound
val float : float -> float t
float bound
A random generator which generates numbers n
satisfying 0.0 <= n <= bound
.
Precondition: 0 <= bound
val bool : bool t
Generate a random boolean value.
val choose : 'a list -> 'a t
uniform lst
Generate a random value of the list lst
.
Precondition: List must not be empty lst <> []