Higher-Order Procedures

map, filter, reduce, folds, for-each, vector/string variants, and apply invoke guest procedures through the evaluator application path.

At a glance

LISPEX
(fold-right cons (list) (list 1 2 3))

Result

OUTPUT
(1 2 3)

Current guarantees

  • Traversal order is left to right and callback errors or escapes propagate through the same signal path.
  • fold-left is the left-reduction alias; fold-right calls (f element accumulator) from the right.
  • for-each runs for effect and returns the profile unspecified result as zero values.

Callback contracts

SignatureTraversal / resultValue context
(map proc list ...)left-to-right; fresh proper listcallback exactly one value
(filter predicate list)left-to-right; retained elementspredicate exactly one value; only #f rejects
(fold-left proc init list)left accumulatorcallback exactly one value
(apply proc arg ... final-list)shared application dispatcher; tail-safeprocedure result packet preserved
(for-each proc list ...)left-to-right effectscallback one value; overall zero values

Boundaries

  • Host callbacks do not bypass guest continuation, handler, or value-context rules.