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

Romain Francois romain at r-enthusiasts.com
Tue Mar 16 12:48:11 CET 2010


Le 16/03/10 12:26, Dirk Eddelbuettel a écrit :
>
>
> 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

I surely expected this. Maybe it could just be "list", after all with 
already have "pairlist".

The reason for make_list : the STL has make_pair.

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7
`- http://tr.im/O1wO : highlight 0.1-5



More information about the Rcpp-devel mailing list