curry: Pre-evaluate arguments of a function

View source: R/all.R

curryR Documentation

Pre-evaluate arguments of a function

Description

To curry a function means to pre-evaluate some of the arguments So, if you have a function sum <- function(a, b) {a + b}

And you always want b to be 1, you could define add.one <- curry(sum, b = 1)

Which is the same as function(a) {a + 1}

Usage

curry(FUN, ...)

Arguments

FUN

the function we are currying

...

the arguments you want to pre-evaluate

Value

the new curried function

Examples

sum <- function(a, b) {a + b}
add.one <- curry(sum, b = 1)
function(a) {a + 1}


adamleerich/alrtools documentation built on March 12, 2024, 11:38 p.m.