Sort.puts: def of bend-parallel@0.1.0.0 Import: import bend-parallel@0.1.0.0/sort.bend as Sort Lines 316-335 of bend-parallel@0.1.0.0/sort.bend: https://jend.leeeet.dev/read.txt?path=bend-parallel@0.1.0.0/sort.bend&start_line=316&end_line=335 import Base # Pass 3's forks: d levels down to the blocks under block i, with two # handles each to the keys, the table and perm. Block i reads only its # keys, reads and writes only its row of the table, and writes perm only # at the slots its row hands it: pass 2 gave each (block, bucket) pair its # own run of slots, so no two lanes write one slot. def puts(+d: Nat, +i: U32, +e: Nat, +kb: Nat, +k: U32, fk: Array & Array, ft: Array & Array, fp: Array & Array) -> Three: match d: case 0n: (ks, ks2) = fk (t, t2) = ft (pm, pm2) = fp three.rejoin(ks2, t2, pm2, puts.leaf(i, e, kb, k, ks, t, pm)) case 1n+p: (k0, k1) = fk (t0, t1) = ft (p0, p1) = fp +j = (i * 2 : U32) l r = puts(p, j, e, kb, k, Array.fork(U32, k0), Array.fork(U32, t0), Array.fork(U32, p0)) puts(p, (j + 1 : U32), e, kb, k, Array.fork(U32, k1), Array.fork(U32, t1), Array.fork(U32, p1)) three.join(l, r) Uses (12): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Array.fork 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.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mul https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=Three https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=puts.leaf https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=three.join https://jend.leeeet.dev/definition.txt?path=bend-parallel@0.1.0.0/sort.bend&name=three.rejoin