Skip to content
Prev 167509 / 398502 Next

lazy evaluation question

Gabor Grothendieck wrote:
Yes. This has nothing to do with lazy evaluation, and everything to do 
with scoping: f is not defined in the scope of F, so does not know about 
its variables (nor those in the implicit loop of lapply()).

Notice also that in

lapply(1:4,function(i) F(i))

it would be pretty weird if lapply would behave differently depending on 
the name of formal arguments of the function, i.e. if

lapply(1:4,function(meep) F(meep))

gave a different result. And f() depends on looking for a variable i 
outside of the function.