From mboxrd@z Thu Jan 1 00:00:00 1970 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes From: "Bart Schaefer" Message-Id: <990126163743.ZM25602@candle.brasslantern.com> Date: Tue, 26 Jan 1999 16:37:43 -0800 In-Reply-To: <990126162520.ZM25560@candle.brasslantern.com> Comments: In reply to "Bart Schaefer" "Re: Example function" (Jan 26, 4:25pm) References: <19990126184200.B27794@fysh.org> <990126162520.ZM25560@candle.brasslantern.com> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: "Bart Schaefer" , Phil Pennock , Zsh Development Workers Subject: Re: Example function MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailing-List: 5038 On Jan 26, 4:25pm, Bart Schaefer wrote: > Subject: Re: Example function > (One of the things on the associative-array wishlist is "reverse pattern" > lookup, that is, treat the array keys as patterns and match them against > the subscript. Then you could do silly stuff like > > typeset -A map > map=('*.(gz|Z)' zcat > '*.bz2' 'bzip2 -dc' > '*.bz' 'bzip -dc' > '*' '<') > eval ${(q)map[$argv[i]]} '$argv[i]' > > where I'm using (q) as the fictional reverse-pattern query flag; probably > there's a better letter.) Incidentally, the reason this isn't there already is that associative arrays are unordered hashes, so you can't predict _which_ pattern will match the subscript when you do the query -- '*' might match before '*.bz' is tried.