| 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: | 2026-05-27 06:35:09 UTC |
| Source: | https://github.com/jimhester/lambda |
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.
f(expr, env = parent.frame())f(expr, env = parent.frame())
expr |
Expression that is the body of the function |
env |
the environment the new function will have |
Reduce(f(.(x) + .(y)), 1:10) compact1 <- f(Filter(Negate(is.null(.(x))))) f(runif(n = rpois(1, 5), .(...)))Reduce(f(.(x) + .(y)), 1:10) compact1 <- f(Filter(Negate(is.null(.(x))))) f(runif(n = rpois(1, 5), .(...)))