def next.grow

emerging-ezjson@1.3.0.0 · src/pull.bend:1555

import emerging-ezjson@1.3.0.0/src/pull.bend as Pull
import Base

1555# a walk that runs level `lvl`, then the next level up, until it finishes or
1556# `left` levels are done. Most events finish at level 0, one step's budget, so
1557# a walk pays for the levels only when it jumps many times
1558def next.grow(left: Nat, +lvl: Nat, res: Out) -> Out:
1559  match left res:
1560    case 1n+pp More{txt, st}:
1561      next.grow(pp, 1n+lvl, next.run(lvl, More{txt, st}))
1562    case _ More{txt, st}:
1563      More{txt, st}
1564    case _ Fin{got}:
1565      Fin{got}

Uses (3)

Used by (1)