def bump.go
import bend-ml-bpe-tokenizer@0.1.3.0/main.bend as BendMlBpeTokenizerimport Base
190# adds 1 to the counter of the pair (a, b), or creates it at the end of the list
191def bump.go(cs: List<&2, Cnt>, hit: Bool, +a: Tk, +b: Tk) -> List<&2, Cnt>:
192 match cs hit:
193 case Nil{} _:
194 Cnt{a, b, 1n} <> Nil{}
195 case Con{Cnt{x, y, +k}, rest} True{}:
196 Cnt{x, y, 1n+k} <> rest
197 case Con{c, +rest} False{}:
198 c <> bump.go(rest, same_head(rest, a, b), a, b)