def ctz_go

bend-collections-laws-math@1.0.0.0 · src/math/f64.bend:1198

import bend-collections-laws-math@1.0.0.0/src/math/f64.bend as F64
import Base
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-math@1.0.0.0/src/math/w64.bend as X

1198# trailing zeros of w (at most fuel), one halving at a time
1199def ctz_go(fuel: Nat, +w: W.U64, odd: Bool) -> Nat:
1200  match fuel odd:
1201    case 0n _:
1202      0n
1203    case 1n+f True{}:
1204      0n
1205    case 1n+f False{}:
1206      1n+ctz_go(f, X.half(w), X.odd(X.half(w)))

Uses (5)

Used by (2)