From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11287 invoked from network); 18 Jan 2004 18:50:47 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 18 Jan 2004 18:50:47 -0000 Received: (qmail 5050 invoked by alias); 18 Jan 2004 18:50:40 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19384 Received: (qmail 5040 invoked from network); 18 Jan 2004 18:50:40 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 18 Jan 2004 18:50:40 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.11.8.53] by sunsite.dk (MessageWall 1.0.8) with SMTP; 18 Jan 2004 18:50:39 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id i0IIocS10082 for zsh-workers@sunsite.dk; Sun, 18 Jan 2004 10:50:38 -0800 From: Bart Schaefer Message-Id: <040118105038.ZM10081@candle.brasslantern.com> Date: Sun, 18 Jan 2004 10:50:38 -0800 In-Reply-To: <87oet2neqo.fsf@naz.lickey.com> Comments: In reply to Matt Armstrong "Re: Is there an idiom for converting an array to an associative array?" (Jan 17, 6:59pm) References: <87vfndnnwe.fsf@naz.lickey.com> <1040116042310.ZM28857@candle.brasslantern.com> <87oet2neqo.fsf@naz.lickey.com> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: Re: Is there an idiom for converting an array to an associative array? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 17, 6:59pm, Matt Armstrong wrote: > Bart Schaefer writes: > > > typeset "assoc[${^array[@]}]=''" > > Thanks, I'll give it a whirl, and then study it for a couple of hours > to figure out how it works. :-) Given array=(a b c), X${^array}Y expands to XaY XbY XcY. Does that help? > > } array=(a b c) > > } set -A assoc > > > > That should be "typeset -A assoc". "set -A" means something entirely > > different. > > I jumped to "To create an empty array (including associative arrays)" > in the text below: > > Associative arrays must be declared before assignment, by using: > > typeset -A name [...] > To create an empty array (including associative arrays), use one of: > > set -A name "set -A name" is a form of assignment, not a form of declaration. Perhaps the word "create" was poorly chosen in that bit of documentation (and that remark is the only reason I'm still sending this to zsh-workers).