Displaying 1 result from an estimated 1 matches for "r46088".
Did you mean:
746088
2008 Jul 21
1
confusion about evaluation.
...on(i) {
function() { i^2 }
})
sapply(1:3, function(i) x[[i]]())
[1] 9 9 9
## does what I expect
x <- lapply(1:3, function(i) {
print(i)
function() { i^2 }
})
[1] 1
[1] 2
[1] 3
sapply(1:3, function(i) x[[i]]())
[1] 1 4 9
> sessionInfo()
R version 2.7.1 Patched (2008-07-20 r46088)
i386-apple-darwin9.4.0
locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base