Skip to content

rand

Random values, ranges, and collection sampling.

Functions

bool

rand::bool(probability?) -> bool

Random boolean, optionally true with probability 0.0..=1.0.

bytes

rand::bytes(n) -> bytes

Random bytes of length n.

choice

rand::choice(list|string|bytes) -> Option

Random element, or None for an empty input.

float

rand::float() / rand::float(max) / rand::float(min, max) -> float

Random float in a half-open range.

int

rand::int() / rand::int(max) / rand::int(min, max) -> int

Random integer. Bounded forms use half-open ranges.

sample

rand::sample(list|bytes, n) -> list|bytes

Random sample without replacement.

shuffle

rand::shuffle(list|bytes) -> list|bytes

Shuffled copy.

Documentation reflects Ion v0.2.0-66-g3faa376.