Std\Random
Random – pseudo-random number generation.
Provides random integers, floats, element selection, and sequence shuffling.
Uses a fast PRNG seeded at program startup. For cryptographically secure
randomness, use Std.Crypto.
Functions
Section titled “Functions”int : Int -> Int -> Int
Section titled “int : Int -> Int -> Int”Generate a random integer in the range [lo, hi] (inclusive).
import int from Std\Random inint 1 100 # => 42 (random)float : Float
Section titled “float : Float”Generate a random float in the range [0.0, 1.0).
import float from Std\Random infloat # => 0.7312... (random)choice : [a] -> Int
Section titled “choice : [a] -> Int”Pick a random element from a sequence. Returns the element.
import choice from Std\Random inchoice [10, 20, 30] # => 20 (random)shuffle : [a] -> [b]
Section titled “shuffle : [a] -> [b]”Return a new sequence with elements in random order.
import shuffle from Std\Random inshuffle [1, 2, 3, 4, 5] # => [3, 1, 5, 2, 4] (random)