Skip to content
Prev 409 / 10988 Next

[Rcpp-devel] CharacterVector::iterator

Hello,

This did not make the cut for Rcpp 0.7.5 which was released yesterday, 
but I've started to play around with CharacterVector::iterator.

Here is another way to say paste( letters, collapse = "" ) using 
std::accumulate :

funx <- cfunction(signature(x = "character"), '
		CharacterVector letters(x) ;
		std::string res(
			std::accumulate(
				letters.begin(), letters.end(), std::string() ) ) ;
		return wrap(res) ;
	;
		', Rcpp = TRUE, includes = "using namespace Rcpp;" )


 > funx( letters )
[1] "abcdefghijklmnopqrstuvwxyz"

Romain