def widest
import cli@0.2.0.0/cli.bend as Cliimport Base
5519# L, the widest left cell w with 2 + w + 2 <= K.
5520def widest(rows: List<&2, Row>, +shorted: Bool, +k: Nat, +best: Nat) -> Nat:
5521 match rows:
5522 case Nil{}: best
5523 case row <> tail:
5524 +w = cell_width(row_cell(row, shorted))
5525 widest(tail, shorted, k,
5526 Bool.pick(Nat, Nat.is_le((w + 4n : Nat), k), Nat.max(w, best), best))