[Rcpp-devel] Good idioms for creating a named list?

Dirk Eddelbuettel edd at debian.org
Tue Mar 16 12:26:27 CET 2010


On 16 March 2010 at 11:49, Romain Francois wrote:
| Hello,
| 
| I have now commited make_list as a set of templates taking variable 
| number of arguments and creating named generic vectors. There is again 
| some code bloat involved and it handles up to 20 arguments. (this is not 
| painful to make it 50 or 100, but I think 20 is good enough for now).
| 
| For example (see more of this in the runit.make.list.R file):
| 
| fx <- cfunction(signature(),'
| 		return make_list(
| 			Named("a") = 1 ,
| 			Named("b") = 2 ,
| 			Named("c") = "foobar",
| 			Named("d") = 4.0 ) ;	
| 	',
| 	Rcpp = TRUE, includes = "using namespace Rcpp; " )

Very nice.  Very useful. And once more Very ugly use of _ --- I would have
called it makeList but heck you code it you get to name it :)

Dirk

-- 
  Registration is open for the 2nd International conference R / Finance 2010
  See http://www.RinFinance.com for details, and see you in Chicago in April!


More information about the Rcpp-devel mailing list