Re: [R] Delayed evaluation / lazy expression evaluation

2017-04-25 Thread Thomas Mailund
If anyone are interested, I found a solution for lazy lists. A simplified version of their construction and access looks like this: nil <- function() NULL cons <- function(car, cdr) {   force(car)   force(cdr)   function() list(car = car, cdr = cdr) } is_nil <- function(lst) is.null(lst()) car <

Re: [R] Delayed evaluation / lazy expression evaluation

2017-04-24 Thread Bert Gunter
There is no way that I have the tenacity to wade through your verbiage (maybe other hardier souls will). However, it sounds like you are trying to reinvent wheels. I think you want: ?substitute. > f <- function(exp)substitute(exp) > f(1:100) 1:100 see also ?delayedAssign for direct manipulation o

[R] Delayed evaluation / lazy expression evaluation

2017-04-24 Thread Thomas Mailund
Hi, I’m playing around with ways of implementing lazy evaluation of expressions. In R, function arguments are evaluated as promises but expressions are evaluated immediately, so I am trying to wrap expressions in thunks—functions with no arguments that evaluate an expression—to get something th