Generic.pow_mod_go: def of bend-collections@1.0.0.0 Import: import bend-collections@1.0.0.0/src/math/generic.bend as Generic Lines 524-533 of bend-collections@1.0.0.0/src/math/generic.bend: https://jend.leeeet.dev/read.txt?path=bend-collections@1.0.0.0/src/math/generic.bend&start_line=524&end_line=533 import Base import bend-collections@1.0.0.0/src/math/num.bend as N # right-to-left binary exponentiation on (e, e == 0), every product reduced # mod m def pow_mod_go(~T: Data, ~op: N.Op -> T, ~test: N.Test -> Bool, fuel: Nat, +m: T, +b: T, +acc: T, st: T & Bool) -> T: match fuel st: case 0n _: acc case 1n+f Tuple{e, True{}}: acc case 1n+f Tuple{+e, False{}}: pow_mod_go(~T, ~op, ~test, f, m, op(N.MulMod{b, b, m}), mm_bit(~T, ~op, test(N.Odd{e}), m, b, acc), zst(~T, ~test, op(N.Half{e}))) Uses (8): 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@1.0.0.0/src/math/generic.bend&name=mm_bit https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/src/math/generic.bend&name=zst https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/src/math/num.bend&name=Op https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/src/math/num.bend&name=Test