def hex4.go
import bend-net-json@0.3.0.0/json.bend as Jsonimport Base
139def hex4.go(s: String, +acc: U32, n: Nat) -> Maybe<&2, Esc>:
140 match s:
141 case SNil{}:
142 match n:
143 case 0n:
144 Some{Esc{acc, SNil{}}}
145 case 1n+k:
146 None{}
147 case SCon{Chr{+c}, t}:
148 match n:
149 case 0n:
150 Some{Esc{acc, SCon{Chr{c}, t}}}
151 case 1n+k:
152 +h = hexd(c)
153 Bool.pick(Maybe<&2, Esc>, U32.is_eq(h, 99), None{}, hex4.go(t, (acc * 16 + h : U32), k))