invert or reverse a string... warning this is a rant
duncan.booth at invalid.invalid
Fri Oct 20 14:43:58 CEST 2006
"Demel, Jeff" <Jeff.Demel at JavelinDirect.com> wrote:
> I've been programming professionally for over 10 years, and have never
> once needed to reverse a string. Maybe it's a lack of imagination on my
> part, but I can't think of a single instance this might be necessary.
I did want to reverse some strings once, but it may have been nearly 10
years ago now.
If I remember correctly the situation was that I wanted to store a lot of
strings on a pda with limited memory and no gzip library. One way of
doing simple compression would be to store them sorted with the first byte
simply containing the number of characters in common with the previous
string. It happened that the strings in question had common suffixes more
than prefixes, so I stored them sorted by the reverse of the strings with a
lead byte containing the number of common characters at the tail of the
Shortly afterwards I ported gzip to the target platform.
More information about the Python-list