def uint32n

bend-collections-laws-crypto@1.0.0.0 · src/math/random/rand.bend:177

import bend-collections-laws-crypto@1.0.0.0/src/math/random/rand.bend as Rand
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as W

177# uniform in [0, n) for n > 0 (Go's Uint32N)
178def uint32n(~S: Data, ~next: S -> W.U64 & S, s: S, +n: U32) -> U32 & S:
179  lo32(S, uint64n(~S, ~next, s, W.U64{n, 0}))

Uses (5)

Used by (1)