def Spans.balance
import bend-lint-rules@0.2.0.0/lib/text/main.bend as BendLintRulesimport Base
123# The node over `l` and `r`, balanced: their heights may differ by two.
124def Spans.balance(+l: Spans, b: U32, e: U32, +r: Spans) -> Spans:
125 +hl = Spans.height(l)
126 +hr = Spans.height(r)
127 Spans.balance.if(U32.is_gt(hl, (hr + 1: U32)), U32.is_gt(hr, (hl + 1: U32)), l, b, e, r)