From: "Johann 'Myrkraverk' Oskarsson" <johann@myrkraverk.com>
To: ZSH Users <zsh-users@sunsite.dk>
Subject: Re: Keying arrays to names: is there an array of arrays?
Date: Sun, 28 May 2006 02:34:10 +0000 [thread overview]
Message-ID: <m3ejyeg9nh.fsf@jin.myrkraverk.com> (raw)
In-Reply-To: <060527151044.ZM25448@torch.brasslantern.com> (Bart Schaefer's message of "Sat, 27 May 2006 15:10:44 -0700")
Bart Schaefer <schaefer@brasslantern.com> writes:
> I'll assume you mean the *associative* array (hash) name.
Yes, thank you very much.
> A function to do the assignment isn't too terrible, though there are
> scoping issues -- either the hash already has to exist, or you can
> only create it in the global scope by using typeset -g:
The following version also works with IFS="" (I guess it will work
with IFS equal to something sensible too).
mapassign() {
local h=$1 k=$2
shift 2
set -- ${(j: :q)*}
typeset -gA $h
typeset -g $h\[$k\]="$*"
}
> A function to read back the value is a bit trickier. What do you want
> to do with the array once you have it? A common fallback would be to
> stuff it in $reply:
Same with this one:
mapread() {
set -- $1\[$2\]
reply=( ${(s: :Q)${(z)${(P)1}}} )
}
> Incidentally:
>
> } I classify Outlook mail as spam, use something else.
>
> Someone asking for assistance has no right to dictate terms. You want
> my help, you take it the way I send it. I don't happen to use Outlook,
> but next time I see something like this, I just won't answer.
That isn't meant for mailing lists, but for private messages. I've
modified my tag line a bit, but it's also your prerogative not to
answer.
--
johann myrkraverk com (you know the drill with the @ and .)
I classify Outlook mail as spam, please use something else for private
messages.
next prev parent reply other threads:[~2006-05-28 2:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-26 14:20 Johann 'Myrkraverk' Oskarsson
2006-05-26 15:26 ` Marc Chantreux
2006-05-26 15:40 ` Peter Stephenson
2006-05-26 15:58 ` Peter Stephenson
2006-05-27 19:09 ` Johann 'Myrkraverk' Oskarsson
2006-05-27 22:10 ` Bart Schaefer
2006-05-28 2:34 ` Johann 'Myrkraverk' Oskarsson [this message]
2006-05-28 18:17 ` Bart Schaefer
2006-05-28 21:32 ` Johann 'Myrkraverk' Oskarsson
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=m3ejyeg9nh.fsf@jin.myrkraverk.com \
--to=johann@myrkraverk.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).