Skip to content
Prev 41907 / 398500 Next

reverse lexicographic order

I wrote:
where "this" was
Thomas Lumley <tlumley at u.washington.edu> suggested
	strrev<- function(ss) {
	    sapply(lapply( strsplit(ss,character(0)), rev), paste, collapse="")
	}
	
Unfortunately, I failed to explain myself clearly, so this doesn't actually
answer the question I _meant_ to ask.  For me, sticking in some variant of
'apply' means you have _failed_ to vectorise.  The string reversal code in
?rev doesn't count for the same reason.

There is no reason why a built-in strrev() couldn't be as vectorised as
most built-ins, it's just not common enough to deserve a lot of effort.