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.

Source for wiki CombinatorsCowan version 9

author

cowan

comment


    

ipnr

127.10.177.1

name

CombinatorsCowan

readonly

0

text

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

== Combinators ==

`(constantly `''obj'' ...`)`

Returns a procedure that always returns the ''obj'' objects as its values, regardless of the number and value of its arguments.

`(complement `''proc''`)`

Returns a procedure that returns the boolean inverse of ''proc''.  That is, it returns `#t` when ''proc'' returns `#f`, and `#f` otherwise.

`(compose `''proc'' ... `)`

Returns a procedure that represents the composition of its arguments.  Any of the procedures may return multiple values, which are passed as arguments to its successor.  With zero arguments, `(compose)` returns a procedure that is functionally equivalent to `values`.

`(simple-compose `''proc'' ...`)`

A variant of `compose` that handles only single-argument single-valued procedures. With zero arguments, returns a procedure that is functionally equivalent to `identity`.

`(conjoin `''predicate'' ...`)`

Returns a procedure that returns `#t` if its arguments satisfy all the ''predicate''s.

`(disjoin `''predicate'' ...`)`

Returns a procedure that returns `#t` if its arguments satisfy any of the ''predicate''s.

`(each `''proc'' ... `)`

Returns a procedure that applies each of the ''proc''s in turn to its arguments, discarding the results and returning an unspecified value.

`(flip `''proc''`)`

Returns a two-argument procedure that calls ''proc'', a two-argument procedure, with its arguments swapped.

`(all-of? `''predicate''`)`

Returns a procedure of one argument that returns `#t` when applied to a list of elements that all satisfy ''predicate'', or `#f` otherwise.

`(any-of? `''predicate''`)`

Returns a procedure of one argument that returns `#t` when applied to a list of elements at least one of which satisfies ''predicate'', or `#f` otherwise.

`(map-reduce `''mapper reducer''`)`

Returns a procedure that maps ''mapper'' to each of its arguments, and then applies ''reducer'' to all the results and returns what it returns.

== Other procedures ==

`(always `''obj''`)`

Ignores its arguments and always returns `#t`. 

`(never `''obj''`)`

Ignores its arguments and always returns `#f`.

`(identity `''obj''`)`

Returns ''obj''.

== Documentation style ==

It's been suggested that the documentation of these combinators is too hard to understand, and should be documented
like this:

`((constantly `''obj'' ...`) `''arg'' ...`)`

Ignores ''args'' and returns ''objs''.

time

2013-06-04 17:13:11

version

9