def comments

bend-lint-rules@0.2.0.0 · layout/imports.bend:52

import bend-lint-rules@0.2.0.0/layout/imports.bend as Imports
import Base
import bend-lint-api@0.2.0.0/shared/strings.bend as Strings

52# The comment lines of `s`, a run of whole lines, each with its newline; blank lines dropped. `line` is the current
53# line, last character first; `acc` the lines so far, last first.
54def comments(s: String, line: String, acc: List<&2, String>) -> String:
55  match s:
56    case SNil{}:
57      Strings.onto(kept(String.reverse(line)) <> acc, "")
58    case SCon{'\n', rest}:
59      comments(rest, "", kept(String.reverse(line)) <> acc)
60    case SCon{c, rest}:
61      comments(rest, SCon{c, line}, acc)

Uses (10)

Used by (1)