def fold

bend-lint-api@0.2.0.0 · linter/lint.bend:344

import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
import Base

344# `f(c, node, s)` for each node of `nodes` and under them, parents first, in order, from `s`.
345def fold(
346  ~C: Data,
347  ~S: Data,
348  ~f: @+c: C -> @+node: Node -> S -> S,
349  +c: C,
350  nodes: List<&2, Node>,
351  s: S
352) -> S:
353  match nodes:
354    case Nil{}:
355      s
356    case Con{Node{syntax, name, span, +kids, facts}, rest}:
357      fold(
358        ~C,
359        ~S,
360        ~f,
361        c,
362        rest,
363        fold(~C, ~S, ~f, c, kids, f(c, Node{syntax, name, span, kids, facts}, s))
364      )

Uses (2)

Used by (4)