def apply.go

bend-lint-rules@0.2.0.0 · lib/text/main.bend:25

import bend-lint-rules@0.2.0.0/lib/text/main.bend as BendLintRules
import Base
import bend-lint-api@0.2.0.0/shared/strings.bend as Strings

25# `rest`, the text from `at` on, with `edits` (in order) made, after the pieces of `out` (last first). The pieces join
26# once, at the end, so the text is copied once, whatever the number of edits.
27def apply.go(edits: List<&2, Edit>, +rest: String, +at: U32, out: List<&2, String>) -> String:
28  match edits:
29    case Nil{}:
30      Strings.onto(rest <> out, "")
31    case Con{Edit{p, beg, +end, text}, more}:
32      apply.go(
33        more,
34        String.drop(rest, U32.to_nat((end - at: U32))),
35        end,
36        text <> Strings.take(rest, U32.to_nat((beg - at: U32))) <> out
37      )

Uses (9)

Used by (1)