obtaining the reversal of a sequence?
Bill Janssen (firstname.lastname@example.org)
Wed, 20 Oct 1993 23:27:57 PDT
I've encountered the problem where I'd like to have a sequence that is
traversed in both directions equally frequently. It's a display list, and
is traversed from back to front, to paint the window, and from front to
back, to find the innermost element enclosing a point.
Clearly, the ``for foo in x'' construct works well for one of the two
cases, but what's the efficient way to traverse the list in reverse order?
The best I can come up with is:
tmp = list[:]
for x in tmp:
and that's so inefficient I believe there must be some trick tucked away
to make this easier.