BendMlBpeTokenizer.merge.go: def of bend-ml-bpe-tokenizer@0.1.3.0 Import: import bend-ml-bpe-tokenizer@0.1.3.0/main.bend as BendMlBpeTokenizer Lines 52-64 of bend-ml-bpe-tokenizer@0.1.3.0/main.bend: https://jend.leeeet.dev/read.txt?path=bend-ml-bpe-tokenizer@0.1.3.0/main.bend&start_line=52&end_line=64 import Base # Replaces each occurrence (non-overlapping, left to right) of the pair # (a, b) with the token c. `hit` is always `peek(a, b, xs)`: the caller computes it, # because a match can only open parameters. def merge.go(xs: List<&2, Tk>, hit: Bool, +a: Tk, +b: Tk, +c: Tk) -> List<&2, Tk>: match xs hit: case Con{x, Con{y, +t}} True{}: c <> merge.go(t, peek(a, b, t), a, b, c) case Con{x, Nil{}} True{}: x <> Nil{} case Con{x, +t} False{}: x <> merge.go(t, peek(a, b, t), a, b, c) case Nil{} _: Nil{} Uses (4): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=bend-ml-bpe-tokenizer@0.1.3.0/main.bend&name=Tk https://jend.leeeet.dev/definition.txt?path=bend-ml-bpe-tokenizer@0.1.3.0/main.bend&name=peek