ilusm.dev

rand

High-level random: shuffle, sample, weighted choice, distributions.

Load with: use rand

Quick example

use rand

result = rndch([1, 2, 3])
prn(result)

Functions

Functions

rndch(xs)

Checks a condition. Takes xs.

rndsh(xs)

Performs the operation. Takes xs.

rndsm(xs, n)

Performs the operation. Takes xs, n.

rndwt(items, weights)

Performs the operation. Takes items, weights.

rndbt(lo, hi)

Performs the operation. Takes lo, hi.

rndfl(lo, hi)

Performs the operation. Takes lo, hi.

rndbl(prob)

Performs the operation. Takes prob.

rnddice(n, sides)

Performs the operation. Takes n, sides.

rnduid()

Performs the operation.

rndnrm(mu, sigma)

Removes an item. Takes mu, sigma.

Module aliases

These are the public-facing names you call with use rand:

  • rand.ch(x)
  • rand.sh(x)
  • rand.sm(x, n)
  • rand.wt(i, w)
  • rand.int(l, h)
  • rand.flt(l, h)
  • rand.bol(p)
  • rand.dice(n, s)
  • rand.uid()
  • rand.nrm(m, s)

Notes

  • Random number generation - uniform, gaussian, choice, shuffle.