Skip to content

random

Module

Type-directed pseudo-random generation of primitive values and pick lists, seeded or unseeded, as single values or infinite generators.

The random module generates pseudo-random data. Generation is type-directed: the type you ask for determines both the value produced and its static output type.

It can produce a single value or an infinite generator (an iterator of values) that composes with take, select, where, and the rest of the iterators module.

Determinism and purity

Filtrera is pure, and random stays consistent with that:

  • Seeded single values are a pure function of (seed, options) — every occurrence of random number { seed = 1 } in a program yields the same value. Use the generator form to get a sequence of distinct values.
  • Generators replay from their seed, so a let-bound generator always produces the same sequence within a run.
  • Unseeded values capture a non-deterministic seed once, at evaluation time — the impurity is contained to that single point, just like newid.

The engine is xoshiro256** seeded via splitmix64, implemented in the runtime so sequences are stable across platforms and .NET versions. Text seeds are hashed with FNV-1a (64-bit).

Exports

random Generates a random value or an infinite generator of a given type.