Re: obtaining the reversal of a sequence?

Dirk Soede (Dirk.Soede@cwi.nl)
Fri, 22 Oct 1993 10:19:38 +0100

>meaning). But someone else proposed that range() return a new object
>type that behaves like a sequence but doesn't store all its elements,
>just returns the one you ask for.

This is the same as in Smalltalk. There a loop is actually a method of a
Sequence which executes the code of the loop on each Sequence element. The
Sequence is only accessed through `first' and `next'. So it can also choose
to generate the next item only when requested. This sounds very clean to
me.

You could also have a reverse loop when Sequences would have methods last
and previous.

>I am beginning to like this solution. It would not be 100 percent
>compatible, since uses of range() in other contexts would work
>differently or not at all (e.g. you can't initialize a list with a
>range and then remove items from it) but those uses would be a far

Maybe when a range object is copied it should have a copy method, which
returns a real list with all elements.

Dirk Soede

Centre for Mathematics & Computer Science (CWI),
Kruislaan 413, 1098 SJ Amsterdam, The Netherlands.
Email:soede@cwi.nl, Tel: +31-20-592 4009