A seeded random sequence that repeats on every run
The complete source of standardTypes_seeded_random.ek9, compiled by the EK9 compiler. Shown on standardTypes.html.
#!ek9 defines module site.standardTypes.seededRandom defines program SeededRandomExample() stdout <- Stdout() //Same seed -> same sequence every run, so output is reproducible rnd <- SeededRandom(42) dice1 <- rnd.next(1, 6) dice2 <- rnd.next(1, 6) stdout.println(`Rolled ${dice1} and ${dice2}`)
Download standardTypes_seeded_random.ek9
Output
Rolled 2 and 5