Hi,
I believe it's lazy evaluation. See ?force
HTH,
baptiste
On 14 February 2010 20:32, Jyotirmoy Bhattacharya
wrote:
> I want to use lapply and a function returning a function in order to build a
> list of functions.
>
>> genr1 <- function(k) {function() {k}}
>> l1 <- lapply(1:2,genr1)
>> l1[
I want to use lapply and a function returning a function in order to build a
list of functions.
> genr1 <- function(k) {function() {k}}
> l1 <- lapply(1:2,genr1)
> l1[[1]]()
[1] 2
This was unexpected. I had expected the answer to be 1, since that is the
value k should be bound to when genr1 is ap
2 matches
Mail list logo