def shuffle_step

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

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

293# swap element i with a uniform j < n = i + 1
294def shuffle_step(~A: Data, ~S: Data, ~next: S -> W.U64 & S, +i: Nat, +n: W.U64, st: List<&2, A> & S) -> List<&2, A> & S:
295  (xs, s) = st
296  swap_at(A, S, xs, i, uint64n(~S, ~next, s, n))

Uses (7)

Used by (2)