Deterministic linear congruential pseudo-random generator with one mutable seed and three derived output views.
seed before returning its derived result.seed reproduces the same output sequence.seed to 0n32.seed before returning its result.nextSeed applies one linear congruential step and stores the result back into seed.seed = seed * 0x8088405n32 + 1n32, with Nat32 wraparound.getr32, getn32, and geti32 each call nextSeed exactly once before returning their derived result.nextSeed (-- seed): returns the updated stored Nat32 seed.getr32 (-- value): converts the updated seed to Real32 and scales it by 2^-32.getn32 (-- value): squares the updated seed in Nat64, shifts right by 32, and casts the result to Nat32.geti32 (-- value): squares the updated seed in Nat64, shifts right by 32, and casts the result to Int32.seed reproduces the same output sequence.seed changes every subsequent derived result."RandomLCG" use
"control" use
{} () {} [
r: RandomLCG;
@r.nextSeed printStack _:;
@r.nextSeed printStack _:;
@r.getr32 printStack _:;
] "main" exportFunction
1n32
134775814n32
0.86105r32
"RandomLCG" use
"control" use
{} () {} [
r: RandomLCG;
@r.nextSeed 1n32 same printStack _:;
@r.nextSeed 134775814n32 same printStack _:;
@r.getr32 0.86105r32 same printStack _:;
] "main" exportFunction
TRUE
TRUE
TRUE
"RandomLCG" use
"String" use
"control" use
{} Int32 {} [
r: RandomLCG;
("seed1=" @r.nextSeed LF
"seed2=" @r.nextSeed LF
"r32=" @r.getr32 LF) printList
0
] "main" exportFunction
seed1=1
seed2=134775814
r32=0.86105