std/random

Types

Rng

pub type Rng = {
    // private fields omitted
}

Deterministic pseudo-random generator (splitmix64); a seed gives the same sequence on the VM and in native builds.

Rng.nextInt

pub fn Rng.nextInt(mut self, bound: Int) -> Int

Uniform integer in 0..bound; bound must be positive.

Rng.nextFloat

pub fn Rng.nextFloat(mut self) -> Float

Uniform Float in [0, 1).

Functions

seeded

pub pure fn seeded(seed: i64) -> Rng

Generator starting from seed, taken as its two's-complement bits.

fromClock

pub fn fromClock() -> Rng

Generator seeded from the clock.