equals: Terser Function Declaration

Description Usage Arguments Details Value Examples

Description

A terse syntax of function declaration for people who are interested in shooting yourself in the foot.

Usage

1
left = right

Arguments

left

A symbol or a function call.

right

A R expression as body of the function.

Details

If left hand side is a symbol, it just do normal assignment like <-.

If left hand side is a function call, e.g. f(x, y), it creates a function named "f" which has formal arguments of "x", "y" and function body defined by the right hand side, in the environment calling it.

Value

The assigned value or function.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
x = 3
x

f(x, y) = x + y
f(2, 3)
identical(f, function(x, y) x + y)

g(x = 231) = log(x)
g()
identical(g, function(x = 231) log(x))

h(a, b = a^2) = a + b
h(1)
h(1, 2)
identical(h, function(a, b = a^2) a + b)

tan2(a) = sin(a)/cos(a)
tan2(pi)

Marlin-Na/terser documentation built on May 17, 2019, 6:21 p.m.