Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: 3.1.5 + associative arrays: keys, values, and pattern subscripts
- X-seq: zsh-workers 4829
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: Re: PATCH: 3.1.5 + associative arrays: keys, values, and pattern subscripts
- Date: Thu, 17 Dec 1998 11:17:14 +0100
- In-reply-to: ""Bart Schaefer""'s message of "Sun, 13 Dec 1998 15:33:32 NFT." <981213153332.ZM15459@xxxxxxxxxxxxxxxxxxxxxxx>
"Bart Schaefer" wrote:
> The appended patch improves the implementation of the (kv) parameter flags
> and their interaction with the (iIrR) subscripting flags.
I finally had a look at these and a couple seem to be giving problems.
For the tests,
% typeset -A assoc
% assoc=(one eins two zwei three drei four vier five funf)
> Associative Array Ordinary Array
> ----------------- --------------
>
> ${(k)param[key]} If key has a value, If key has a value,
> then key, else empty then key, else empty
% print ${(k)assoc[four]}
0
although
% print ${(k)assoc[(i)four]}
four
> $param[(r)pat] A value in param that First value in param that
> matches pattern pat matches pattern pat
% print ${assoc[(r)v*]}
eins
although
% print ${assoc[(R)v*]}
vier
and
% print ${(v)assoc[(r)v*]}
vier
The remaining cases as far as I've tested seem fine. There is of
course the point that the ordering is random (the `first' match of
something could be any of them), but that's a feature of associative
arrays which just needs to be made clear in the docs. The syntax
seems as good as anything I can think of.
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author