1 # src/rchars: a buffer of chars read one at a time and consed on the front 2 # (the last read first) as the String it spells, in one pass: each char goes 3 # onto the String built so far, with no reversed list in between (the shape 4 # `fromrev`, U016, reports). Pure. 5 import Base 6 7 # the buffer's chars, first read first, then acc 8 def onto(buf: List<&2, Char>, acc: String) -> String: 9 match buf: 10 case Nil{}: 11 acc 12 case Con{h, t}: 13 onto(t, SCon{h, acc}) 14 15 # the buffer's chars, first read first 16 def text(buf: List<&2, Char>) -> String: 17 onto(buf, SNil{})