def gcd_go
bend-collections-laws-crypto@1.0.0.0 · src/math/generic.bend:200
import bend-collections-laws-crypto@1.0.0.0/src/math/generic.bend as Generic
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/num.bend as N
200
201def gcd_go(~T: Data, ~op: N.Op<T> -> T, ~test: N.Test<T> -> Bool, fuel: Nat, +a: T, st: T & Bool) -> T:
202 match fuel st:
203 case 0n _:
204 a
205 case 1n+f Tuple{b, True{}}:
206 a
207 case 1n+f Tuple{+b, False{}}:
208 gcd_go(~T, ~op, ~test, f, b, zst(~T, ~test, op(N.Rem{a, b})))