Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idiom # 69: Seed random generator

See programming-idioms.org:

Random number generators in Fuzion are effects. To use a random number generator with a particular seed, we have to instate the effect Random with the given seed and run code with this effect in its environment. The standard library feature Random.simple creates such a random provider with the given seed and installs it as the environment for running the code provided with the function parameter f.

Code

Runnable Example

The following example provides a feature seed that executes a function f with in an environment with a seeded random number generator. For illustration, show_random is called in this context and also in the default random provider and an explicitly time seeded random provider:

last changed: 2026-07-23