lcons: Creates a pair, the right value is promised (by making...

Description Usage Arguments Value References Examples

Description

The idea and funcition names mainly comes from Scheme (Gauche) and Haskell. see References

Usage

1
2
3
lhs %:% rhs

lcons(lhs, rhs)

Arguments

lhs

car part

rhs

cdr part

Value

lazy cons of lhs and rhs.

References

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# R's infix operator has left-associativity
# run
1 %:% (2 %:% (3 %:% lempty))

# can be parsed but not llist
1 %:% 2 %:% 3 %:% lempty

# repeat 1L as an infinit sequence
ones <- 1L %:% ones

# this was privous version of lcons that evaluate a cdr part as eager-eval.
`%:%` <- lcons <- function(x, y) {
  `class<-`(pairlist(head = x, tail = function() y), "lcons")
}

TobCap/lazystreamr documentation built on May 9, 2019, 4:50 p.m.