Random.shuffle.go: def of bend-kit-random@0.1.0.1 Import: import bend-kit-random@0.1.0.1/random.bend as Random Lines 109-119 of bend-kit-random@0.1.0.1/random.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-random@0.1.0.1/random.bend&start_line=109&end_line=119 import Base # Fisher-Yates: at slot i, jr is below(i + 1); slot i swaps with slot j. # At k = 0, i is 0 and below(1) drew nothing. def shuffle.go(~T: Data, k: Nat, +i: U32, a: Array, jr: U32 & Rng) -> Array & Rng: match k: case 0n: (j, r) = jr (a, r) case 1n+p: (+j, r) = jr shuffle.go(~T, p, (i - 1 : U32), shuffle.swap(~T, i, j, Array.get(T, a, i)), below(i, r)) Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.get https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=bend-kit-random@0.1.0.1/random.bend&name=Rng https://jend.leeeet.dev/definition.txt?path=bend-kit-random@0.1.0.1/random.bend&name=below https://jend.leeeet.dev/definition.txt?path=bend-kit-random@0.1.0.1/random.bend&name=shuffle.swap