def val.digits

bend-osdev-acpi@0.1.1.0 · aml_value.bend:138

import bend-osdev-acpi@0.1.1.0/aml_value.bend as AmlValue
import Base
import bend-osdev-word64@0.1.1.0/word64.bend as W

138# digits from the front of a string, up to the first other character or
139# n digits; m: the first character's digit value
140def val.digits(n: Nat, xs: List<&2, U32>, m: Maybe<&2, U32>, acc: W.W64, +hex: Bool) -> W.W64:
141  match n:
142    case 0n:
143      acc
144    case 1n+p:
145      match xs:
146        case Nil{}:
147          acc
148        case Con{h, +t}:
149          match m:
150            case None{}:
151              acc
152            case Some{d}:
153              val.digits(p, t, val.dig.head(hex, t), W.W64.add(W.W64.mul(acc, val.base(hex)), W.W64.from_u32(d)), hex)

Uses (11)

Used by (2)