Scan.until.go: def of gralha-text-scan@0.1.0.1 Import: import gralha-text-scan@0.1.0.1/scan.bend as Scan Lines 65-75 of gralha-text-scan@0.1.0.1/scan.bend: https://jend.leeeet.dev/read.txt?path=gralha-text-scan@0.1.0.1/scan.bend&start_line=65&end_line=75 import Base # Scanning loops decide each character one step ahead (`hit` says whether # `c`, the character before `t`, ends the scan), so the rest of the text is # only ever held once: a shared tail would make every step pay for the # sharing. The rest comes first, as the argument that shrinks. def until.go(t: String, hit: Bool, +c: U32, +end: U32, acc: String) -> Scan: match t hit: case t True{}: Scan{rev(acc, ""), t} case SNil{} False{}: Scan{rev(SCon{Chr{c}, acc}, ""), ""} case SCon{Chr{c2}, t2} False{}: +cc = c2 until.go(t2, U32.is_eq(cc, end), cc, end, SCon{Chr{c}, acc}) Uses (7): 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=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_eq https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=Scan https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=rev