def Digit.from_char.find
import bend-trace-context@0.2.0.0/src/hex.bend as Heximport Base
329# Search the encoder's own alphabet, so an accepted character is exactly the
330# encoding of the digit returned for it.
331def Digit.from_char.find(digits: List<&2, Digit>, +char: Char) -> Maybe<&2, Digit>:
332 match digits:
333 case Nil{}:
334 None{}
335 case Con{+digit, tail}:
336 Bool.pick(Maybe<&2, Digit>, Char.is_eq(char, Digit.to_char(digit)),
337 Some{digit}, Digit.from_char.find(tail, char))