This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see CombinatorsCowan in WG2's repo for R7RS-large.

Combinators­Cowan

cowan
2014-12-08 04:46:36
11history
source

This proposal contains various procedures that return procedures and a few others, drawn from Chicken. Common Lisp has a few of them too.

Combinators

The documentation style rather than showing only how the procedures are invoked, also shows how the returned procedures would be invoked, in order to make the descriptions easier to understand.

((constantly obj ...) arg ...)

Returns the obj objects as its values, ignoring args.

((complement proc) obj)

Returns #t when (''proc obj'') returns #f, and #f` otherwise.

((compose proc ... ) arg ...)

Passes the args to the first proc, which returns any number of values. These are then passed to the next proc, and so on until the final proc is reached. If there are no procs, returns its arguments as values.

((simple-compose proc ...) arg)

Passes arg to the first proc, which returns one value. This is then passed to the next proc, and so on until the final proc is reached. If there are no procs, returns its argument.

((conjoin predicate ...) arg ...)

Returns #t if the args satisfy all the predicates, and #f otherwise.

((disjoin predicate ...) arg ...)

Returns #t if the args satisfy any of the predicates.

((each proc ... ) arg ...)

Applies each of the procs in turn to args, discarding the results and returning an unspecified value.

((flip proc) arg1 arg2)

Returns (proc arg2 arg1).

((all-of? predicate)

Applies predicate to each element of list in turn, and immediately returns #f if predicate is not satisfied by that element; otherwise returns #t.

((any-of? predicate) list)

Applies predicate to each element of list in turn, and immediately returns #t if predicate is satisfied by that element; otherwise returns #f.

((map-reduce mapper reducer) list)

Returns `(apply ''reducer'' (''mapper list''))`.

Other procedures

(always obj)

Ignores its arguments and always returns #t.

(never obj)

Ignores its arguments and always returns #f.

(identity obj)

Returns obj.