In perl 6, the statement  

            @foo = (1.. 5) ;

    is equivalent to

            @foo = (1, 2, 3, 4, 5); 

 

Is there similar shorthand to set @foo = (5, 3, 3, 2, 1) ?  I know you can
go

            @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.  Would

            @foo = (5 .. 1 :by(-1));

do the trick?  If so, would the same trick work for

            @bar = ('e' .. 'a' :by(-1)); ?

 

Joe Gottman

 



Reply via email to