def perm
import bend-collections@1.0.0.0/src/math/random/rand.bend as Randimport Base
import bend-collections@1.0.0.0/src/math/u64.bend as W
322# Go's Perm: a shuffle of 0..n-1
323def perm(~S: Data, ~next: S -> W.U64 & S, s: S, +n: Nat) -> List<&2, Nat> & S:
324 shuffle(~Nat, ~S, ~next, s, range(n))