rand
Random numbers for simulations, games, and similar uses.
Draws use ECMAScript Math.random:
approximately uniform, engine-defined, unseeded, and not reproducible across runs or engines.
They are not cryptographically secure; never use them for tokens, access codes, or UUIDs.
These procedures run only as statements,
so expressions, including the steps of map, cannot draw. Draw in a procedure and store the result.
Write these names after rand::, as in rand::unit.
unit
proc unit()! numReturns an approximately uniform number from 0 up to but excluding 1.
int
proc int(start! num, end! num)! numReturns an approximately uniform integer from start up to but excluding end; rand::int(1, 7) rolls a die.
Bounds must be safe integers with start < end and a span of at most 2^53; otherwise the call fails with Conflict.
units
proc units(count! num)* num -> numDraws count independent unit values as index -> value, with indices from zero and multiplicity one.
Indices keep equal draws distinct and pair separate draws; they do not order Bag enumeration.
The count must be a nonnegative integer within the Bag-total limit; otherwise the call fails with Conflict.
Work limits use ordinary LimitExceeded failures without publishing partial results.
ints
proc ints(count! num, start! num, end! num)* num -> numDraws count independent int values as index -> value, with the same indices, count rules, and limits as
units. Bounds follow int and are validated even when the count is zero.