Series.scan: def of bend-visgraph@2.0.0.0 Import: import bend-visgraph@2.0.0.0/src/series.bend as Series Lines 28-41 of bend-visgraph@2.0.0.0/src/series.bend: https://jend.leeeet.dev/read.txt?path=bend-visgraph@2.0.0.0/src/series.bend&start_line=28&end_line=41 import Base # Base's String.lines recurses once per character, too deep for the JS # lane's stack, so this walks the text with tail calls. `h` is the character # before `s`, `nl` whether it is a newline, and `cur` the line before `h`, # last character first. def scan(s: String, nl: Bool, +h: Char, cur: String, +line: U32, st: Parsed) -> Parsed: match s nl: case SNil{} True{}: step(String.reverse(cur), line, st) case SNil{} False{}: step(String.reverse(SCon{h, cur}), line, st) case SCon{+h2, t} True{}: scan(t, Char.is_eq(h2, '\n'), h2, SNil{}, (line + 1 : U32), step(String.reverse(cur), line, st)) case SCon{+h2, t} False{}: scan(t, Char.is_eq(h2, '\n'), h2, SCon{h, cur}, line, st) Uses (9): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Char https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Char.is_eq https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.reverse https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=bend-visgraph@2.0.0.0/src/series.bend&name=Parsed https://jend.leeeet.dev/definition.txt?path=bend-visgraph@2.0.0.0/src/series.bend&name=step