On Fri, Sep 03, 2004 at 08:09:23AM -0400, Joe Gottman wrote: > > > > -----Original Message----- > > From: Larry Wall [mailto:[EMAIL PROTECTED] > > Sent: Thursday, September 02, 2004 8:41 PM > > To: Perl6 > > Subject: Re: Reverse .. operator > > > > On Thu, Sep 02, 2004 at 08:34:22PM -0400, Joe Gottman wrote: > > : Is there similar shorthand to set @foo = (5, 3, 3, 2, 1) ? [...] > > : @foo = reverse (1 ..5); > > : > > : but this has the major disadvantage that it cannot be evaluated lazily; > > : reverse has to see the entire list before it can emit the first element > > of > > : the reversed list. > > > > I don't see any reason why it can't be evaluated lazily. The .. produces > > a range object that gets shoved into the lazy list that gets bound to > > the slurp array of reverse(). If you pop that, there's no reason it > > couldn't go out and ask the end of the lazy list for its last element. > > Just have to make .. objects smart enough to deal off either end of > > the deck. > > I get it. One way to implement this would to give the .. object a > .reverse member iterator that lazily iterates from right to left,
Hey look: bidirectional iterators. Cool. ;> --Dks