def bloop

bend-collections-laws-math@1.0.0.0 · src/math/generic.bend:244

import bend-collections-laws-math@1.0.0.0/src/math/generic.bend as Generic
import Base
import bend-collections-laws-math@1.0.0.0/src/math/num.bend as N

244# (a odd, (d, d == 0, small)): once a and d fit the instance's small type
245# (Small), their gcd is taken there (GcdSmall: U64 runs Euclid on U32)
246def bloop(~T: Data, ~op: N.Op<T> -> T, ~test: N.Test<T> -> Bool, fuel: Nat, st: T & (T & (Bool & Bool))) -> T:
247  match fuel st:
248    case 0n Tuple{a, x}:
249      a
250    case 1n+f Tuple{a, Tuple{d, Tuple{True{}, sm}}}:
251      a
252    case 1n+f Tuple{+a, Tuple{+d, Tuple{False{}, True{}}}}:
253      op(N.GcdSmall{a, d})
254    case 1n+f Tuple{+a, Tuple{+d, Tuple{False{}, False{}}}}:
255      bloop(~T, ~op, ~test, f, bnx(~T, ~op, ~test, a, strip(~T, ~op, ~test, d)))

Uses (8)

Used by (4)