From: "Ara.T.Howard" Date: 2004-08-04T09:42:07+09:00 Subject: Re: Fastest way to reverse-process a string? On Wed, 4 Aug 2004, 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? > > Thanks in advance. > > > -- > Lloyd Zusman > ljz@asfast.com > God bless you. ~ > ruby -e 's="raboof"; (s.size - 1).downto(0){|i| print s[i].chr}; puts' foobar -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================