Natural.mid: def of bend-collections-laws-math@1.0.0.0 Import: import bend-collections-laws-math@1.0.0.0/src/math/natural.bend as Natural Lines 171-176 of bend-collections-laws-math@1.0.0.0/src/math/natural.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-math@1.0.0.0/src/math/natural.bend&start_line=171&end_line=176 import Base # Binary search for the last r in [lo, hi) where the test holds, given it # holds at lo and fails at hi (reference section 8.5 notes the float-sqrt # shortcut is wrong above 2^52; this search is exact). `more` is lo + 1 < hi # and `ok` is the test at the midpoint; the fuel bounds the halvings. def mid(+lo: Nat, +hi: Nat) -> Nat: Nat.div(Nat.add(lo, hi), 2n) Uses (3): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div