def unhex.go

bend-kit-bytes@0.3.3.0 · bytes.bend:658

import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import Base

658# hi is the previous digit; an odd i completes a byte.
659def unhex.go(s: String, a: Array<U32>, +i: U32, +hi: U32, +ok: Bool) -> Array<U32> & Bool:
660  match s:
661    case SNil{}:
662      (a, ok)
663    case SCon{Chr{+c}, t}:
664      +d = unnibble(c)
665      unhex.go(t, poke.when(U32.is_eq((i .&. 1 : U32), 1), a, (i >> 1n : U32), ((hi << 4n) .|. d : U32)), (i + 1 : U32), d, Bool.and(ok, U32.is_lt(d, 16)))

Uses (17)

Used by (1)