R does this sort of thing easily without any parse/eval acrobatics needed.
E.g., you can do:
> stu <- function(x) {return( 1 + (2*x*x) - (3*x) )}
> (x <- 0:3)
[1] 0 1 2 3
> stu(x)
[1] 1 0 3 10
> metafun <- function(FUN, data) FUN(data)
> metafun(stu, x)
[1] 1 0 3 10
> # if you want
Hi.
I'm looking for an R equivalent to something like function pointers in C/C++.
I have a search procedure that evaluates the fitness of each point it reaches
as it moves along, and decides where to move next based on its fitness
evaluation. I want to be able to pass different fitness func
2 matches
Mail list logo