zsh-users
 help / color / mirror / code / Atom feed
From: Steve Talley <stephen.talley@sun.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@sunsite.dk
Subject: Re: Reverse the order of an array?
Date: Fri, 8 Feb 2002 16:55:36 -0700	[thread overview]
Message-ID: <20020208165535.D10334@thpppt> (raw)
In-Reply-To: <Pine.BSF.4.40.0202082239301.90676-100000@brasslantern.com>; 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 }


  reply	other threads:[~2002-02-08 23:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-08 22:35 Steve Talley
2002-02-08 22:59 ` Bart Schaefer
2002-02-08 23:55   ` Steve Talley [this message]
2002-02-09  0:09     ` Bart Schaefer
2002-02-09  0:17       ` Steve Talley
2002-02-11 13:26       ` Oliver Kiddle
2002-02-11 18:41         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020208165535.D10334@thpppt \
    --to=stephen.talley@sun.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).