def hangul.dec
import bend-kit-unicode@0.1.0.0/unicode.bend as Unicodeimport Base
17# Hangul syllables decompose and compose by formula (Unicode §3.12).
18def hangul.dec(+s: U32) -> String:
19 +t = (s % 28 : U32)
20 tail = Bool.pick(String, U32.is_eq(t, 0), SNil{}, SCon{Chr{(4519 + t : U32)}, SNil{}})
21 SCon{Chr{(4352 + (s / 588) : U32)}, SCon{Chr{(4449 + ((s % 588) / 28) : U32)}, tail}}