curry
function and the %<%< code=""> operator performs currying on
a function by partially applying the first argument, returning a function
that accepts all but the first arguments of the former function. If the first
argument 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).
fun %<% arg<="" div="">
curry(fun, arg)
fun
except for the
first, unless the first is ...
in which case it will be retained.
partial
,
tail_curry
# Equivalent to curry(`+`, 5)
add_5 <- `+` %<% 5
add_5(10)
# ellipsis are retained when currying
bind_5 <- cbind %<% 5
bind_5(1:10)
Run the code above in your browser using DataLab