zsh-users
 help / color / mirror / code / Atom feed
From: Justin M Wozniak <jwozniak@cse.nd.edu>
To: zsh-users@sunsite.dk
Subject: Re: print entire array *with* subscript?
Date: Fri, 10 Feb 2006 23:15:41 -0500 (EST)	[thread overview]
Message-ID: <Pine.GSO.4.58.0602102314580.139@cse.nd.edu> (raw)
In-Reply-To: <EXCHANGE03XHbQbilav0000bbe8@exchange03.csr.com>


In your solution, what is the point of (r) ?

-- 
Justin Michael Joseph Wozniak

On Fri, 10 Feb 2006, Peter Stephenson wrote:

> Jean-Rene David wrote:
> > It would be nice to be able to do this:
> >
> > print ${(k)files}
> > 1 foo.h 2 foo.c 3 bar.h 4 bar.c
> >
> > instead of:
> >
> > for f in {1..$#files}; do
> >   print $f ${files[$f]};
> > done
> >
> > Not a big deal. Just asking because that's what I
> > thought the documentation meant.
>
> I think the documentation for the (k) flag is (for once) reasonably
> clear and accurate:
>
>        k      If  name  refers  to  an  associative array, substitute the keys
>               (element names) rather than the values of  the  elements.   Used
>               with  subscripts  (including  ordinary arrays), force indices or
>               keys to be substituted even if the subscript form refers to val-
>               ues.   However,  this  flag  may  not be combined with subscript
>               ranges.
>
> This means you can use it with normal arrays, but only with individual
> indices.  So:
>
> % print ${(k)files[(r)foo.c]}
> 2
>
> but it doesn't work with a subscript nor with a range nor with the *
> and @ subscripts (which are special ranges).
>
> That doesn't mean this is convenient...
>
>


  reply	other threads:[~2006-02-11  4:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200602101756.59858.arvidjaar@mail.ru>
2006-02-10 17:50 ` Jean-Rene David
2006-02-10 18:03   ` Peter Stephenson
2006-02-11  4:15     ` Justin M Wozniak [this message]
2006-02-11  5:20       ` Bart Schaefer
2006-02-09 19:40 Jean-Rene David

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=Pine.GSO.4.58.0602102314580.139@cse.nd.edu \
    --to=jwozniak@cse.nd.edu \
    --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).