* is a key of pointed key set ? (where is the + )
@ 2006-11-06 8:04 Marc Chantreux
2006-11-06 8:20 ` Andrey Borzenkov
0 siblings, 1 reply; 5+ messages in thread
From: Marc Chantreux @ 2006-11-06 8:04 UTC (permalink / raw)
To: zsh-users
Hi all,
See this code:
pnt=h
typeset -A h
h=( k1 value )
so :
echo ${${(P)pnt}[k1]}
prints value
but how to know if the key itself is set ? i've tried some of those
syntaxes :
not $+{${(P)pnt}[k1]}
not ${+${(P)pnt}[k1]}
but it failed. I'm sure someone can help :)
regards
--
téléphone : 03.90.24.00.19
courriel : marc.chantreux@ulpmm.u-strasbg.fr
---------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is a key of pointed key set ? (where is the + )
2006-11-06 8:04 is a key of pointed key set ? (where is the + ) Marc Chantreux
@ 2006-11-06 8:20 ` Andrey Borzenkov
2006-11-06 10:13 ` Marc Chantreux
0 siblings, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2006-11-06 8:20 UTC (permalink / raw)
To: zsh-users; +Cc: Marc Chantreux
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 06 November 2006 11:04, Marc Chantreux wrote:
> Hi all,
>
> See this code:
>
> pnt=h
> typeset -A h
> h=( k1 value )
>
> so :
>
> echo ${${(P)pnt}[k1]}
> prints value
>
> but how to know if the key itself is set ?
{pts/0}% typeset -A h
{pts/0}% h=(k v)
{pts/0}% print -- ${(k)h[k]+set}
set
{pts/0}% print -- ${(k)h[k1]-unset}
unset
- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFFTvA9R6LMutpd94wRAlZNAJwLesklZ5N2tuHvm/tKfvw2wtgqUgCfYBkm
Z33cKWv8KRvmBY0ZQ7FBbWE=
=5lhJ
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is a key of pointed key set ? (where is the + )
2006-11-06 8:20 ` Andrey Borzenkov
@ 2006-11-06 10:13 ` Marc Chantreux
2006-11-06 11:11 ` Andrey Borzenkov
0 siblings, 1 reply; 5+ messages in thread
From: Marc Chantreux @ 2006-11-06 10:13 UTC (permalink / raw)
To: zsh-users
le 06/11/2006,
Andrey Borzenkov nous écrivait :
> > pnt=h
> > typeset -A h
> > h=( k1 value )
> >
> > so :
> >
> > echo ${${(P)pnt}[k1]}
> > prints value
> >
> > but how to know if the key itself is set ?
>
> {pts/0}% typeset -A h
> {pts/0}% h=(k v)
> {pts/0}% print -- ${(k)h[k]+set}
> set
> {pts/0}% print -- ${(k)h[k1]-unset}
> unset
well .. (( $+h[k] )) does the same. You missed a part of the problem :
my associative array is "Pointed" (P).
so we can imagine :
[[ -n ${(k)${(P)pnt}[k1]} ]] && print "${pnt}[k1] is set"
but it doesn't work.
thanks for help
mc
--
téléphone : 03.90.24.00.19
courriel : marc.chantreux@ulpmm.u-strasbg.fr
---------------------------------------
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is a key of pointed key set ? (where is the + )
2006-11-06 10:13 ` Marc Chantreux
@ 2006-11-06 11:11 ` Andrey Borzenkov
2006-11-06 13:14 ` Marc Chantreux
0 siblings, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2006-11-06 11:11 UTC (permalink / raw)
To: zsh-users
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 06 November 2006 13:13, Marc Chantreux wrote:
> le 06/11/2006,
>
> Andrey Borzenkov nous écrivait :
> > > pnt=h
> > > typeset -A h
> > > h=( k1 value )
> > >
> > > so :
> > >
> > > echo ${${(P)pnt}[k1]}
> > > prints value
> > >
> > > but how to know if the key itself is set ?
> >
> > {pts/0}% typeset -A h
> > {pts/0}% h=(k v)
> > {pts/0}% print -- ${(k)h[k]+set}
> > set
> > {pts/0}% print -- ${(k)h[k1]-unset}
> > unset
>
> well .. (( $+h[k] )) does the same. You missed a part of the problem :
> my associative array is "Pointed" (P).
>
Somewhat kludgy but
{pts/0}% typeset -A h
{pts/0}% h=(k1 v1 k2 v2)
{pts/0}% p=h
{pts/0}% print -- ${${(Pk)p}[(r)k3]-unset}
unset
{pts/0}% print -- ${${(Pk)p}[(r)k2]+set}
set
> so we can imagine :
>
> [[ -n ${(k)${(P)pnt}[k1]} ]] && print "${pnt}[k1] is set"
>
> but it doesn't work.
>
I believe this was discussed recently. Parameter type is not propagated from
nested substitutions, so this is not going to work. Outside of innermost
${...} you just get list of values. Even without (P):
{pts/0}% print -- ${(k)${h}}
v1 v2
{pts/0}% print -- ${(k)${(kv)h}}
k1 v1 k2 v2
- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFFTxhwR6LMutpd94wRApfCAJ9Q3/5QdxdTGPmBQIm3cn9YqItL3ACfeZpZ
70APA+FBiocoEIHj/NY7Mpk=
=Y63j
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is a key of pointed key set ? (where is the + )
2006-11-06 11:11 ` Andrey Borzenkov
@ 2006-11-06 13:14 ` Marc Chantreux
0 siblings, 0 replies; 5+ messages in thread
From: Marc Chantreux @ 2006-11-06 13:14 UTC (permalink / raw)
To: zsh-users
Andrey Borzenkov wrote:
> Somewhat kludgy but
yes it is :) but ...
> I believe this was discussed recently. Parameter type is not propagated from
> nested substitutions, so this is not going to work. Outside of innermost
> ${...} you just get list of values. Even without (P):
misunderstood this point: i'll search into the archives.
regards
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-11-06 13:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-06 8:04 is a key of pointed key set ? (where is the + ) Marc Chantreux
2006-11-06 8:20 ` Andrey Borzenkov
2006-11-06 10:13 ` Marc Chantreux
2006-11-06 11:11 ` Andrey Borzenkov
2006-11-06 13:14 ` Marc Chantreux
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).