def shuffle.read

bend-kit-random@0.1.0.1 · random.bend:121

import bend-kit-random@0.1.0.1/random.bend as Random
import Base

121# Slots [0, k] of the array, with ax the read of slot k, prepended to acc.
122def shuffle.read(~T: Data, k: Nat, ax: Array<T> & T, acc: List<&2, T>) -> List<&2, T>:
123  match k:
124    case 0n:
125      (a, x) = ax
126      x <> acc
127    case 1n+(+p):
128      (a, x) = ax
129      shuffle.read(~T, p, Array.get(T, a, U32.from_nat(p)), x <> acc)

Uses (7)

Used by (1)