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

Idiom # 70: Use clock as random generator seed

See programming-idioms.org:

Random numbers generators in Fuzion are effects. To use a random number generator seeded by a clock, we have to create an instance of timeSeededRandomProvider and run code with this this effect in its environment. The standard library feature timeSeededRandom creates such a random provider and installs it as the environment for running the code provided with the function parameter f.

Code

Running Example

The following example calls showRandom in the context of an explicitly time seeded random provider: