def gcd_go

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

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

200# Euclid's algorithm on (a, (b, b == 0))
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})))

Uses (7)

Used by (1)