Random
Pseudo-random value generation functions in the random namespace.
random::bool
0-parameter signature
random::bool()
bool draws a non-cryptographic pseudo-random Boolean from the Session source.
- Parameters
- None
- Returns
BooleanTrue or false with equal probability, consuming the shared random sequence.
random::choice
1-parameter signature
random::choice(values)
choice selects one uniformly distributed value using the Session's pseudo-random source.
Reservoir sampling takes O(n) time and O(1) additional storage.
- Parameters
valuesAny[]Input list, traversed once without copying or modifying it.
- Returns
AnyOne original value, or None for an empty list. Empty and singleton lists consume no randomness.- Throws
TypeErrorThe argument is not a List.
random::float
0-parameter signature
random::float()
float draws a non-cryptographic pseudo-random number from the Session source.
- Parameters
- None
- Returns
FloatA number in the half-open interval [0, 1).
2-parameter signature
random::float(min, max)
float draws a non-cryptographic pseudo-random number between finite bounds.
- Parameters
minInt | FloatInclusive lower bound; must be finite and not exceed max.maxInt | FloatExclusive upper bound; must be finite.
- Returns
FloatA number in [min, max), or Float(min) for equal bounds without drawing. Original numeric bounds are preserved for unequal intervals.- Throws
TypeErrorA bound is not a native Int or Float.InvalidArgumentBounds are non-finite, reversed, or unequal with no representable Float in the interval.
random::int
2-parameter signature
random::int(min, max)
int draws a non-cryptographic pseudo-random integer between inclusive bounds.
- Parameters
minIntInclusive lower bound; must not exceed max. Floats are not coerced.maxIntInclusive upper bound, including the maximum supported Int.
- Returns
IntA uniformly distributed integer in [min, max]. Equal bounds return min without drawing.- Throws
TypeErrorA bound is not an Int.InvalidArgumentThe minimum exceeds the maximum.
random::shuffle
1-parameter signature
random::shuffle(values)
shuffle randomizes the input values using the Session's pseudo-random source.
Materialization and Fisher-Yates use O(n) append/swap operations; their cost
and the destination's storage depend on the source's collection backend.
- Parameters
valuesListInput list, traversed once and never modified. Its factory creates the destination; values retain their identity.
- Returns
ListA new list preserving the source's implementation family and backend configuration, containing the original values in randomized order. Empty and singleton lists consume no randomness.- Throws
TypeErrorThe argument is not a List.