lib/newRandom.spl)A custom pseudo-random generator written in SPL: multiple internal states, modular mixing, and an “entropy” layer based on digit-to-letter mapping and ASCII binary folding. This is not suitable for cryptography or security-sensitive use.
Load with use newRandom; (extensionless allowed via
reqFileExtension.setVar(false);). Modulus
newRandom_M is 2147483647.
use newRandom; function.newRandom_setSeed(12345); print.number(function.newRandom_randInt(1, 6));
function.newRandom_setSeed(s) — clamps s, resets streams, returns clamped seed.function.newRandom_numToLetters(n) — builds a string from digits (used internally).function.newRandom_entropyLayer(seed) — extra mixing for the entropy step.function.newRandom_mixOnce() — one full update of internal state.function.newRandom_next() — three mixOnce calls; returns current seed.function.newRandom_randFloat01() — float in [0, 1).function.newRandom_randInt(lo, hi) — inclusive integer range.function.newRandom_randFloatRange(lo, hi) — linear interpolation between bounds.
Implementation: someProgrammingLanguage/lib/newRandom.spl