Random.below.go: def of bend-kit-random@0.1.0.1 Import: import bend-kit-random@0.1.0.1/random.bend as Random Lines 54-64 of bend-kit-random@0.1.0.1/random.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-random@0.1.0.1/random.bend&start_line=54&end_line=64 import Base # Rejects draws below t = 2^32 mod n, as OpenBSD's arc4random_uniform does. def below.go(fuel: Nat, +n: U32, +t: U32, xr: U32 & Rng) -> U32 & Rng: match fuel: case 0n: (x, r) = xr ((x % n : U32), r) case 1n+p: (+x, +r) = xr Bool.case(U32 & Rng, U32.is_ge(x, t), u => ((x % n : U32), r), u => below.go(p, n, t, next(r))) Uses (9): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat 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=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_ge https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mod https://jend.leeeet.dev/definition.txt?path=bend-kit-random@0.1.0.1/random.bend&name=Bool.case https://jend.leeeet.dev/definition.txt?path=bend-kit-random@0.1.0.1/random.bend&name=Rng https://jend.leeeet.dev/definition.txt?path=bend-kit-random@0.1.0.1/random.bend&name=next