doc.txt

Combinators: Useful, higher-order functions.

_Combinators: Useful, higher-order functions._

Written by: Carl Eastlund (cce at ccs dot neu dot edu)
Keywords: _combinator_, _combinators_, _higher-order_

This software is distributed under a BSD-style license (see license.txt).

================================================================================

Functions provided by _combinators.ss_:

> ((curry f arg ...) more ...) = (f arg ... more ...)

This combinator partially applies its first argument.  Its remaining arguments
become the initial arguments to f; it produces a function which takes the final
arguments.

> ((yrruc f arg ...) more ...) = (f more ... arg ...)

This combinator partially applies its first argument.  Its remaining arguments
become the final arguments to f; it produces a function which takes the initial
arguments.

> (constant v) = (lambda (arg ...) v)

This combinator produces a function with a constant return value.

> (compose/apply f1 ... fn) = (lambda args (apply f1 ... (apply fn args)))

This combinator composes several functions such that the last argument is
applied first.  The output of each function is passed as the list of arguments
to the next.

> (map2 f (list a1 ... ak) ...) = (values (list b1 ... bk) (list c1 ... ck))
  where (f ai ...) = (values bi ci)

This combinator maps a function of two return values over one or more lists. It
produces two lists representing all the first and second values, respectively,
of the applications of the function.

> (map/values n f (list a1 ... ak) ...) = (values (list b11 ... bk1) ... (list b1n ... bkn))
  where (f ai ...) = (values bi1 ... bin)

This combinator maps a function of n return values over one or more lists. It
produces k lists representing the lists of the respective values returned
by the function on the given inputs.

> (fold/values f (list b0 ...) (list a1 ... an) ...) = (values bn ...)
  where (f ai ... b(i-1) ...) = (values bi ...)

This combinator folds a function of multiple inputs and multiple outputs over
lists of input values.

> ((negate predicate) arg ...) = (not (predicate arg ...))

This combinator produces a function whose result is the boolean opposite of
predicate's.

> ((conjoin predicate ...) arg ...) = (and (predicate arg ...) ...)

This combinator produces a function which is satisfied on a set of arguments
whenever all of the original predicates are.

> ((disjoin predicate ...) arg ...) = (or (predicate arg ...) ...)

This combinator produces a function which is satisfied on a set of arguments
whenever any of the original predicates are.