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 10

author

cowan

comment


    

ipnr

127.11.51.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 ==

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 ''predicate''s.

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

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

`((flip `''proc''`)` ''arg1 arg2''`)`

Returns `(`''proc arg2 arg1''`)`.

`((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''`)` ''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''`)`

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

== Other procedures ==

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

Ignores its arguments and always returns `#t`. 

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

Ignores its arguments and always returns `#f`.

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

Returns ''obj''.

time

2014-12-08 04:43:08

version

10