[Rcpp-devel] sugar version of apply

Dirk Eddelbuettel edd at debian.org
Thu Jul 8 14:15:01 CEST 2010


On 8 July 2010 at 14:06, Romain Francois wrote:
| Hello,
| 
| Now that we have extended sugar so that it can deal with matrices, e.g :
| 
| signature( x = "numeric", y = "numeric" ),
| 				'
| 				NumericVector xx(x) ;
| 				NumericVector yy(y);
| 				NumericMatrix m = outer( xx, yy, std::plus<double>() ) ;
| 				return m ;
| 				'		)
| 
| 
| 
| I'd like to have a sugar version of apply. We cannot retain the same 
| interface :
| 
| apply( { matrix expression }, { 1 or 2 }, { function } )
| 
| because we need compile time dispatch, which is not possible with the 
| second argument. So I'm just wondering how we should call the row and 
| column versions:
| 
| apply_1
| apply_2
| apply_row
| apply_col
| col_apply
| row_apply
| 
| Any preference ?

I like the last two, and I'd drop the underscore for camelCase.  applyRow and
applyCol would also work. The first two I like the least.

-- 
  Regards, Dirk


More information about the Rcpp-devel mailing list