Skip to content
Prev 41904 / 398500 Next

reverse lexicographic order

On Tue, 16 Dec 2003, Richard A. O'Keefe wrote:

            
strrev<- function(ss) {
	sapply(lapply( strsplit(ss,character(0)), rev), paste, collapse="")
}

vectorises the strsplit() part and should be at least a little faster than
loops for the rev and paste operations.

On the other hand, on my laptop, for 100 copies of the text produced by
license() your version takes about 1.6 seconds and mine takes about 1.5.
If this were to be used a lot it would make sense to code it in C.

	-thomas