Rcpp - Define a C++ function that takes an R function and an ellipsis argument -


i have r function bar takes r function foo, defined follows:

foo <- function(x,y) x + y bar <- function(foo, z, ...) z + foo(...) 

a call bar of form:

bar(foo, 1,2,3) 

now foo defined above, want create c++ version of bar. here's i've tried:

library(rcpp) cppfunction( '   double bar(function foo, double z, ...) {   return z + foo(...);  }  ') 

this doesn't work. right way define function in c++?

thanks.

it might easier turn ellipsis list before feeding rcpp

bar <- function(foo, z, ...) {    args <- list(...)    bar_internal(foo, z, args) } 

and rcpp function can take rcpp::list instead of ellipsis.

double bar_internal(function foo, double z, list args){  } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -