def partition

bend-edit-distance@0.2.2.0 · src/Batch.bend:104

import bend-edit-distance@0.2.2.0/src/Batch.bend as Batch
import Base

104# Largest estimated jobs go to the lighter branch. Capacity bounds keep both
105# child counts within ceil(n/2), including zero/rounded/equal work estimates.
106def partition(jobs: List<&2, WeightedJob>, groups: Group & Group) -> Group & Group:
107  match jobs:
108    case Nil{}:
109      groups
110    case job <> tail:
111      (+left, +right) = groups
112      partition(tail, place(job, left, right, choose(left, right)))

Uses (7)

Used by (1)