Learn R Programming

wrapr (version 1.1.1)

lambda: Build an anonymous function.

Description

Mostly just a place-holder so lambda-symbol form has somewhere safe to hang its help entry.

Usage

lambda(..., env = parent.frame())

Arguments

...

formal parameters of function, unbound names, followed by function body (code/language).

env

environment to work in

Value

user defined function.

Examples

Run this code
# NOT RUN {
#lambda-syntax: lambda(arg [, arg]*, body [, env=env])
# also works with lambda character as function name
# print(intToUtf8(0x03BB))

# example: square numbers
sapply(1:4, lambda(x, x^2))

# example more than one argumnet
f <- lambda(x, y, x+y)
f(2,4)

# formula interface syntax: [~arg|arg(~arg)+] := body
f <- x~y := x + 3 * y
f(5, 47)

# }

Run the code above in your browser using DataLab