Re: [R] Curious behaviour of lapply and lists of functions

2014-01-15 Thread Julio Sergio Santana
Julio Sergio Santana gmail.com> writes: > ... > Producer <- function(f) function(x) 1/f(x) > Counsulting a previous post, I got to the solution, I just need to rewrite the function Producer forcing it to eavaluate its argument, as follows Producer <- function(f) {f ;function(x) 1/f(x)

[R] Curious behaviour of lapply and lists of functions

2014-01-15 Thread Julio Sergio Santana
Let's say I define a simple list of functions, as follows lf <- list( function(x) x+5, function(x) 2*x ) Then I can take any individual function from the list and use it with any value, as it is shown: lf[[1]](3) [1] 8 lf[[2]](3) [1] 6 this gives me