def digits

bend-collections@1.0.0.0 · spec/crypto/secp256k1/field.bend:17

import bend-collections@1.0.0.0/spec/crypto/secp256k1/field.bend as Field
import Base
import bend-collections@1.0.0.0/spec/lib/common.bend as C

17# a number from its little-endian radix-2^16 digits, each scaled by one:
18# digits(1, [d0, d1, ...]) = d0 + 2^16 d1 + ...
19def digits(+one: Nat, ds: List<&2, Nat>) -> Nat:
20  match ds:
21    case Nil{}:
22      0n
23    case d <> dt:
24      Nat.add(Nat.mul(one, d), C.shift(16n, digits(one, dt)))

Uses (5)

Used by (4)