Generic.bit_length_go: def of bend-collections-laws-crypto@1.0.0.0 Import: import bend-collections-laws-crypto@1.0.0.0/src/math/generic.bend as Generic Lines 348-356 of bend-collections-laws-crypto@1.0.0.0/src/math/generic.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-crypto@1.0.0.0/src/math/generic.bend&start_line=348&end_line=356 import Base import bend-collections-laws-crypto@1.0.0.0/src/math/num.bend as N # the number of halvings to reach zero def bit_length_go(~T: Data, ~op: N.Op -> T, ~test: N.Test -> Bool, fuel: Nat, +k: Nat, st: T & Bool) -> Nat: match fuel st: case 0n _: k case 1n+f Tuple{n, True{}}: k case 1n+f Tuple{+n, False{}}: bit_length_go(~T, ~op, ~test, f, 1n+k, zst(~T, ~test, op(N.Half{n}))) Uses (7): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Sigma https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/math/generic.bend&name=zst https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/math/num.bend&name=Op https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-crypto@1.0.0.0/src/math/num.bend&name=Test