def depth.go
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytesimport Base
23# The fewest d with 2^d >= w.
24def depth.go(f: Nat, more: Bool, +w: U32, +d: Nat, +cap: U32) -> Nat:
25 match f:
26 case 0n:
27 d
28 case 1n+p:
29 match more:
30 case False{}:
31 d
32 case True{}:
33 depth.go(p, U32.is_lt((cap * 2 : U32), w), w, 1n+d, (cap * 2 : U32))