def cut
bend-visgraph@2.0.0.0 · parallel.bend:74
import bend-visgraph@2.0.0.0/parallel.bend as Parallel
import Base
import bend-visgraph@2.0.0.0/visgraph.bend as VG
74def cut(count: Nat, +i: U32, lr: Array<U32> & U32, rr: Array<U32> & U32, +start: U32, +acc: U32, +target: U32, cs: Chunks, +m: U32) -> Cut:
75 match count:
76 case 0n:
77 (lefts, l) = lr
78 (rights, r) = rr
79 +last = U32.is_lt(start, i)
80 Cut{lefts, rights, close(last, start, i, cs), VG.pick_u32(last, (m + 1 : U32), m)}
81 case 1n+c:
82 (lefts, +l) = lr
83 (rights, +r) = rr
84 +w = (acc + l + r + 1 : U32)
85 +full = U32.is_ge(w, target)
86 +i2 = (i + 1 : U32)
87 cut(c, i2, Array.get(U32, lefts, i2), Array.get(U32, rights, i2), VG.pick_u32(full, i2, start), VG.pick_u32(full, 0, w), target, close(full, start, i2, cs), VG.pick_u32(full, (m + 1 : U32), m))