partial {curry} | R Documentation |
Apply arguments partially to a function
Description
The partial
function and the %><%
operator allows you to
partially call a function with a list of arguments. Named elements in the
list will be matched to function arguments and these arguments will be
removed from the returned function. Unnamed elements are only allowed for
functions containing an ellipsis, in which case they are considered part of
the ellipsis.
Usage
fun %><% args
partial(fun, args)
Arguments
fun |
A function to be partially applied. Can be any function (normal, already partially applied, primitives). |
args |
A list of values that should be applied to the function. |
Value
A function with the same arguments as fun
except for the ones
given in args
Note
Multiple partial application does not result in multiple nested calls, so while the first partial call adds a layer around the called function, potentially adding a very small performance hit, partially calling multiple times will not add to this effect.
See Also
Other partials: curry
,
tail_curry
Examples
dummy_lengths <- vapply %><% list(FUN = length, FUN.VALUE = integer(1))
test_list <- list(a = 1:5, b = 1:10)
dummy_lengths(test_list)