Learn R Programming

curry (version 0.1.1)

partial: Apply arguments partially to a function

Description

The partial function and the %><%< code=""> 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<="" div="">
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

See Also

Other partials: curry, tail_curry

Examples

Run this code
dummy_lengths <- vapply %><% list(FUN = length, FUN.VALUE = integer(1))
test_list <- list(a = 1:5, b = 1:10)
dummy_lengths(test_list)

Run the code above in your browser using DataLab