Package 'lambda'

Title: Simple anonymous functions
Description: Defines a function 'f()' 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 '.()'.
Authors: Jim Hester [aut, cre]
Maintainer: Jim Hester <[email protected]>
License: MIT
Version: 0.0.0.9000
Built: 2024-11-18 05:08:50 UTC
Source: https://github.com/jimhester/lambda

Help Index


Simple anonymous functions

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

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

Arguments

expr

Expression that is the body of the function

env

the environment the new function will have

Examples

Reduce(f(.(x) + .(y)), 1:10)

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

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