I am following Hadley Wickham's Advanced R, and working through an example on lazy evaluation.
I first create an add function as :
> add <- function(x){
+ function(y) x+y
+ }
Then I use apply function on it as :
adders <- lapply(1:10, add)
Now according to the book, due to lazy evaluation in R, when I try,
adders[[1]](20)
should yield answer as 10 + 20 = 30, but for me it gives the answer 21.
> adders[[1]](20)
[1] 21
Any suggestions on why is the lazy evaluation not working on expected lines ?