Re: [Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-18 Thread Romain Francois
Hello, As a follow up on this thread, I've now commited a lazy version of sapply. It can be used with a functor that has a nested result_type type, or raw functions as illustrated by these examples from the unit tests: test.sugar.sapply <- function( ){ inc <- ' template

Re: [Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-16 Thread Douglas Bates
By the way, you were correct in your original response that all I really need is input_transform but it is certainly a worthwhile exercise to see how traits, etc. are used and I appreciate your kind explanations. On Wed, Jun 16, 2010 at 10:58 AM, Romain Francois wrote: > Le 16/06/10 17:44, Dougla

Re: [Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-16 Thread Romain Francois
Le 16/06/10 17:44, Douglas Bates a écrit : Thank you very much, Romain. This certainly helps my understanding of unary_function, traits, etc. These are the sorts of things I can read about but until I see a non-trivial usage it is hard to keep these ideas straight. Two minor questions occur t

Re: [Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-16 Thread Douglas Bates
Thank you very much, Romain. This certainly helps my understanding of unary_function, traits, etc. These are the sorts of things I can read about but until I see a non-trivial usage it is hard to keep these ideas straight. Two minor questions occur to me at this point. In my code I assigned the

Re: [Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-16 Thread Romain Francois
Small update incorporating the use of all (and using namespace Rcpp to make things slightly less cluterred). require( Rcpp ) require( inline ) inc <- ' using namespace Rcpp ; template Vector< traits::r_sexptype_traits< typename FUN::result_type>::rtype > sapply(const OBJECT& object, FUN fu

Re: [Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-16 Thread Romain Francois
Le 16/06/10 14:58, Douglas Bates a écrit : Ever since I read Phil Spector's book on S I have been a fan of functional programming in S and R. When Jose Pinheiro and I were working on the nlme package there was a joke between us that you could tell which of us wrote which parts of the code beca

[Rcpp-devel] Rcpp internal versions of lapply and sapply

2010-06-16 Thread Douglas Bates
Ever since I read Phil Spector's book on S I have been a fan of functional programming in S and R. When Jose Pinheiro and I were working on the nlme package there was a joke between us that you could tell which of us wrote which parts of the code because his parts always had an object named "aux"