Concurrency.par_map.list.go: def of bend-kit-concurrency@0.2.0.0 Import: import bend-kit-concurrency@0.2.0.0/concurrency.bend as Concurrency Lines 43-59 of bend-kit-concurrency@0.2.0.0/concurrency.bend: https://jend.leeeet.dev/read.txt?path=bend-kit-concurrency@0.2.0.0/concurrency.bend&start_line=43&end_line=59 import Base # lr holds two halves of nl and nr elements. Depth d runs 2^(d+1) parallel parts. def par_map.list.go( ~A: Type, ~B: Type, ~f: A -> B, d: Nat, +nl: Nat, +nr: Nat, lr: List & List ) -> List: match d: case 0n: (l, r) = lr lo hi = List.map(~A, ~B, ~f, l) List.map(~A, ~B, ~f, r) List.append(&1, B, lo, hi) case 1n+ +p: (l, r) = lr +hl = Nat.div(nl, 2n) +hr = Nat.div(nr, 2n) ls = split(A, l, hl) rs = split(A, r, hr) lo hi = par_map.list.go(~A, ~B, ~f, p, hl, Nat.sub(nl, hl), ls) par_map.list.go(~A, ~B, ~f, p, hr, Nat.sub(nr, hr), rs) List.append(&1, B, lo, hi) Uses (9): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.map https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub 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=bend-kit-concurrency@0.2.0.0/concurrency.bend&name=split