def hex
import bolt@1.27.0.0/src/lsp/proto.bend as Protoimport Base
260# a hex digit's value: 0-9, then a-f and A-F as 10-15
261def hex(ch: Char) -> U32:
262 +x = Char.to_u32(ch)
263 Bool.pick(U32, U32.is_le(x, 57), (x - 48 : U32),
264 Bool.pick(U32, U32.is_ge(x, 97), (x - 87 : U32), (x - 55 : U32)))