def Mag.inc

bend-kit-bignum@0.1.0.0 · bigint.bend:56

import bend-kit-bignum@0.1.0.0/bigint.bend as Bigint
import Base

56# The limbs are 0 or 1 in z: z says the carry c is 0, so a stays as is.
57def Mag.inc(a: List<&2, U32>, z: Bool, +c: U32) -> List<&2, U32>:
58  match a z:
59    case s True{}:
60      s
61    case Nil{} False{}:
62      Con{c, Nil{}}
63    case Con{x, xs} False{}:
64      +t = (x + c : U32)
65      +k = (t / 10000 : U32)
66      Con{(t % 10000 : U32), Mag.inc(xs, U32.is_zero(k), k)}

Uses (7)

Used by (1)