Description Usage Arguments Value Note See Also Examples
The tail_curry
function and the %-<%
operator performs
currying on a function by partially applying the last argument, returning a
function that accepts all but the last arguments of the former function. If
the last argument is ...
the curried argument will be interpreted as
the last named argument. If the only argument to the function is ...
the curried argument will be interpreted as part of the ellipsis and the
ellipsis will be retained in the returned function. It is thus possible to
curry functions comtaining ellipis arguments to infinity (though not
adviced).
1 2 3 | fun %-<% arg
tail_curry(fun, arg)
|
fun |
A function to be curried from the end. Can be any function (normal, already (tail_)curried, primitives). |
arg |
The value that should be applied to the last argument. |
A function with the same arguments as fun
except for the
last named argument, unless the only one is ...
in which case it will
be retained.
Multiple tail_currying does not result in multiple nested calls, so while the first tail_currying adds a layer around the curried function, potentially adding a very small performance hit, tail_currying multiple times will not add to this effect.
Other partials: curry
, partial
1 2 3 4 5 6 | # Equivalent to tail_curry(`/`, 5)
divide_by_5 <- `/` %-<% 5
divide_by_5(10)
no_factors <- data.frame %-<% FALSE
no_factors(x = letters[1:5])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.