Just a suggestion re: recursion with Rcpp, yet another nice way we can recurse is through using the sugar lapply:
----- #include <Rcpp.h> using namespace Rcpp; // [[Rcpp::export]] RObject add_attr(RObject x_) { RObject x = clone(x_); if (is<List>(x)) { x = wrap( lapply( as<List>(x), add_attr ) ); } else { x.attr("type") = "Other"; } return x; } /*** R add_attr( list(x=list(a=1, b=2, c=3), y=list( list( d=4 ) ) ) ) */ ----- If we want to operate on specific elements as well, we can use is<T> and as<T> together, and then operate on objects as needed. It lets us avoid an explicit for loop, and 'feels' more like R. -Kevin
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel