From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22272 invoked from network); 8 Feb 2002 23:56:05 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 8 Feb 2002 23:56:05 -0000 Received: (qmail 26690 invoked by alias); 8 Feb 2002 23:55:45 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4668 Received: (qmail 26669 invoked from network); 8 Feb 2002 23:55:43 -0000 Date: Fri, 8 Feb 2002 16:55:36 -0700 From: Steve Talley To: Bart Schaefer Cc: zsh-users@sunsite.dk Subject: Re: Reverse the order of an array? Message-ID: <20020208165535.D10334@thpppt> References: <20020208153514.C10334@thpppt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from schaefer@brasslantern.com on Fri, Feb 08, 2002 at 10:59:37PM +0000 Thanks Bart. The best that I had come up with was: indexes=({$#osvers..1}) tmp=('$osvers['$^indexes']') osvers=${(e)tmp} Do you see any way (other than skipping the whole thing :) to simplify this? Thanks, Steve Bart Schaefer wrote: > On Fri, 8 Feb 2002, Steve Talley wrote: > > > How can I easily reverse the order of an array in zsh? > > Depends what you mean by "easily." > > > I was hoping that something like > > > > osvers=($osvers[{$#osvers..1}]) > > > > would work, but no luck. > > Array "slices" in zsh only have start and end points, and are always in > ascending order by numeric position in the array. So you can't do this > purely with parameter expansion in the general case. > > This works: > > for ((i=$#osvers; i>0; --i)) { osvers[i*2]=($osvers[1]); shift osvers }