Batch.plan: def of bend-edit-distance@0.2.2.0 Import: import bend-edit-distance@0.2.2.0/src/Batch.bend as Batch Lines 123-136 of bend-edit-distance@0.2.2.0/src/Batch.bend: https://jend.leeeet.dev/read.txt?path=bend-edit-distance@0.2.2.0/src/Batch.bend&start_line=123&end_line=136 import Base def plan(fuel: Nat, jobs: List<&2, WeightedJob>) -> Plan: match fuel jobs: case _ Nil{}: Empty{} case _ WeightedJob{index, _, job} <> Nil{}: Leaf{index, job} case 0n values: Serial{values} case Succ{+p} +values: +count = List.length(&2, WeightedJob, values) +half = Nat.div(count, 2n) plan_step(partition(values, (Group{half, 0.0, Nil{}}, Group{Nat.sub(count, half), 0.0, Nil{}})), left => right => Fork{plan(p, left), plan(p, right)}) Uses (11): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.length 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=Sigma https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Batch.bend&name=Group https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Batch.bend&name=Plan https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Batch.bend&name=WeightedJob https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Batch.bend&name=partition https://jend.leeeet.dev/definition.txt?path=bend-edit-distance@0.2.2.0/src/Batch.bend&name=plan_step