def tlines_go

bend-prot@0.1.0.0 · pdb.bend:29

import bend-prot@0.1.0.0/pdb.bend as Pdb
import Base

29# Tail-recursive lines(): single self-call in tail position, so long files
30# do not grow the machine stack (String.split recurses per character).
31def tlines_go(s: String, cur: String, acc: List<&2, String>) -> List<&2, String>:
32  match s:
33    case SNil{}:
34      List.reverse(&2, String, String.reverse(cur) <> acc)
35    case SCon{'\n', t}:
36      tlines_go(t, SNil{}, String.reverse(cur) <> acc)
37    case SCon{h, t}:
38      tlines_go(t, SCon{h, cur}, acc)

Uses (9)

Used by (1)