Rand.below_go: def of bend-collections-laws-crypto@1.0.0.0 Import: import bend-collections-laws-crypto@1.0.0.0/spec/math/random/rand.bend as Rand Lines 92-105 of bend-collections-laws-crypto@1.0.0.0/spec/math/random/rand.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/math/random/rand.bend&start_line=92&end_line=105 import Base import bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend as C import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as W import bend-collections-laws-crypto@1.0.0.0/spec/math/w64.bend as SW import bend-collections-laws-crypto@1.0.0.0/spec/math/random/source.bend as SRC # the bounded draw once a draw of x (with verdict m) has left state s: m if # accepted, else (while fuel lasts) the next draw; with no fuel left, the # last candidate floor(x n / 2^64). The verdict is matched before the # recursion, so a draw that is not yet decided keeps the rest unexpanded. def below_go(~S: Data, ~next: S -> W.U64 & S, fuel: Nat, +n: Nat, m: Maybe<&2, Nat>, +x: Nat, +s: S) -> Nat & S: match fuel m: case 0n Some{k}: (k, s) case 0n None{}: (C.high(64n, Nat.mul(x, n)), s) case 1n+f Some{k}: (k, s) case 1n+f None{}: below_go(~S, ~next, f, n, draw(64n, SW.value(SRC.fst64(S, next(s))), n), SW.value(SRC.fst64(S, next(s))), SRC.snd64(S, next(s))) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mul https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend&name=high https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/math/random/rand.bend&name=draw https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/math/random/source.bend&name=fst64 https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/math/random/source.bend&name=snd64 https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/spec/math/w64.bend&name=value https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend&name=U64