fun/rng-state.bruijn
# MIT License, Copyright (c) 2024 Marvin Borner
# generates three pseudo-random integers using a state monad
# printf <seed:number> | bruijn rng-state.bruijn
:import std/Combinator .
:import std/String .
:import std/Number .
:import std/Monad/State .
max (+1000)
rand [[[0 1 1]] rng]
rng (+1103515245) ⋅ 0 + (+12345) % max
rand-bool map even? rand
# normal bind
triple rand >>= [rand >>= [rand >>= [pure [0 1 2 3]]]]
:test ((triple (+50) [[1]] [[[0]]]) =? (+595)) ([[1]])
main string→number → triple → &[[1]]