Tree.build: def of bend-lawful-stdlib@0.1.0.0 Import: import bend-lawful-stdlib@0.1.0.0/src/tree.bend as Tree Lines 40-48 of bend-lawful-stdlib@0.1.0.0/src/tree.bend: https://jend.leeeet.dev/read.txt?path=bend-lawful-stdlib@0.1.0.0/src/tree.bend&start_line=40&end_line=48 import Base # a balanced tree with 2^d leaves f(lo), f(lo+1), ..., so both halves of # each parallel call do the same amount of work def build(~A: Data, ~f: Nat -> A, +d: Nat, +lo: Nat) -> Tree: match d: case 0n: Tip{f(lo)} case 1n+p: l r = build(~A, ~f, p, lo) build(~A, ~f, p, Nat.add(lo, Nat.pow(2n, p))) Fork{l, r} Uses (4): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.pow https://jend.leeeet.dev/definition.txt?path=bend-lawful-stdlib@0.1.0.0/src/tree.bend&name=Tree