f: Simple anonymous functions

Description Usage Arguments Examples

View source: R/package.R

Description

Function to create anonymous functions (lambdas) in a very concise manner. Simply write the body of the function as you would normally. If you want a given variable to appear as one of the arguments to the function, put it in .(). Default arguments can be specified as you normally would in the argument list.

Usage

1
f(expr, env = parent.frame())

Arguments

expr

Expression that is the body of the function

env

the environment the new function will have

Examples

1
2
3
4
5
Reduce(f(.(x) + .(y)), 1:10)

compact1 <- f(Filter(Negate(is.null(.(x)))))

f(runif(n = rpois(1, 5), .(...)))

jimhester/lambda documentation built on May 19, 2019, 10:32 a.m.