From: Joel VanderWerf Date: 2004-08-04T09:15:26+09:00 Subject: Re: Fastest way to reverse-process a string? Lloyd Zusman wrote: > In a ruby program I'm writing, I want to parse a string in reverse and > feed each of its individual characters through a state machine. > > A "hammer and tongs" solution looks like this: > > string.reverse.split(//).each { > |ch| > feedIntoStateMachine(ch) > } > > However, this seems rather inefficient. Does anyone know of a faster > algorithm for this in ruby? String#each_byte would avoid the creation of the array.