cons: LISP-like Functions

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/functional.R

Description

For the LISPstalgics.

Usage

1
2
3
4
cons(a, b)
car(x)
cdr(x)
cadr(x)

Arguments

a

first object to cons.

b

second object to cons.

x

consed object.

Value

cons returns a functions that takes another function as an argument. car, cdr and cadr return the objects initially consed.

Author(s)

Antoine Filipovic Pierucci

References

SICP.

See Also

list.

Examples

1
2
3
a <- cons(rnorm(10), data.frame(a = 1:5, b = 6:10))
car(a)
cdr(a)

Example output

 [1] -0.49934808 -1.89100780  0.09473402  0.12910010  0.77717785  1.37506196
 [7] -0.30162548  0.03677105 -1.06662469 -0.81817875
  a  b
1 1  6
2 2  7
3 3  8
4 4  9
5 5 10

rmngb documentation built on May 29, 2017, 9:22 p.m.

Related to cons in rmngb...