* Array index
@ 1997-11-03 8:27 Bernd Eggink
0 siblings, 0 replies; only message in thread
From: Bernd Eggink @ 1997-11-03 8:27 UTC (permalink / raw)
To: Zsh-workers
What is the easiest way to find the index of a specific element in an
array, apart from using a for loop? The statement
(( i = array[(i)$value] ))
fails if $value contains special characters like parentheses. I tried
quotes on different parts of the expression, but without success.
Example:
x='a(b)'
arr=($x bla)
print $arr[(i)$x] # 3
print $arr[(i)"$x"] # 3
print $arr["(i)$x"] # zsh: bad math expression: unbalanced stack
Any ideas?
Bernd
--
Bernd Eggink
Regionales Rechenzentrum der Universitaet Hamburg
eggink@rrz.uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-11-03 8:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-03 8:27 Array index Bernd Eggink
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).