def shuffle_go

bend-collections@1.0.0.0 · src/math/random/rand.bend:298

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

298# i = k, k - 1, ..., 1 with the bound n = i + 1 as a 64-bit word
299def shuffle_go(~A: Data, ~S: Data, ~next: S -> W.U64 & S, k: Nat, +n: W.U64, st: List<&2, A> & S) -> List<&2, A> & S:
300  match k:
301    case 0n:
302      st
303    case 1n+ +p:
304      shuffle_go(~A, ~S, ~next, p, X.sub(n, W.U64{1, 0}), shuffle_step(~A, ~S, ~next, 1n+p, n, st))

Uses (6)

Used by (1)