Description Usage Arguments Details Value See Also Examples
Function composition is a common operation in functional programming.
Given some number of input functions, these functions return new functions
which represents the composition of the inputs. That is, for three functions
f, g, h, compose(f, g, h)
returns a function equivalent for all x to
f(g(h(x))). composeM
handles the case of functions of multiple
arguments.
1 2 3 | compose(..., where = parent.frame())
composeM(..., where = parent.frame())
|
... |
Objects to compose. See 'Details'. |
where |
An environment in which to resolve any character or symbol arguments. |
For compose
, the functions passed must all take a single argument.
For composeM
, the functions passed must take n >= 1 arguments, and
return a list or vector. composeM
's returned function proceeds right
to left through the functions it composes, applying each to the sequence of
arguments returned by the previous function (via do.call
). The
first function is called with the actual arguments passed.
If some of the ...
arguments are not function objects, they are
resolved to function objects in the following way: character arguments
are looked up in the provided where
environment; symbol arguments
are coerced to character and then looked up in the where
environment;
other types of arguments, or symbol/character arguments which fail to
resolve to a function object, raise an error.
A function representing the composition of the arguments.
curry
, lazy.curry
and uncurry
,
which are frequently useful in conjunction with compose
.
1 2 3 4 5 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.