Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Reverse the order of an array?
- X-seq: zsh-users 4671
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Steve Talley <stephen.talley@xxxxxxx>
- Subject: Re: Reverse the order of an array?
- Date: Mon, 11 Feb 2002 13:26:20 +0000 (GMT)
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <Pine.BSF.4.40.0202082359000.90676-100000@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
--- Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Hmm, I should have thought of that.
>
> eval osvers\=\( \"\$osvers\[{$#osvers..1}\]\" \)
>
Not very intuitive that is it.
I recently wanted to loop over an array's elements in reverse and
though I could do it with a for loop counting the indices backwards I
did think that there ought to be a better way.
Allowing array slices to go backwards, is a possibility though I'd not
be suprised if implementing it caused other things to break. The
easiest might be a parameter expension flag (r and R are gone so we'd
need a letter. ^ perhaps as we used that for the reversed prompt
state). Does anyone else have any views on whether we should add
something for this and if so how?
Oliver
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author