zsh-users
 help / color / mirror / code / Atom feed
* printing arrays and index
@ 2005-07-22 18:08 zzapper
  2005-07-23  4:59 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: zzapper @ 2005-07-22 18:08 UTC (permalink / raw)
  To: zsh-users

Hi,
I'm using

print -C 1 $filessubject

To display the contents of the above array one entry per line

(thanx to this a previous posting in this NG)

I know want to precede each array entry with it's index number 1,2,3, etc

how do?


-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: printing arrays and index
  2005-07-22 18:08 printing arrays and index zzapper
@ 2005-07-23  4:59 ` Bart Schaefer
  2005-07-24  6:46   ` zzapper
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2005-07-23  4:59 UTC (permalink / raw)
  To: zsh-users

On Jul 22,  7:08pm, zzapper wrote:
} Subject: printing arrays and index
}
} I'm using
} 
} print -C 1 $filessubject

I was sort of puzzled by why that was suggested.  "print -l" (that's a
lowercase L, not a one) has the same effect, and works in a lot more
versions of zsh (the -C option is a very recent addition).
 
} I know want to precede each array entry with it's index number 1,2,3, etc
} 
} how do?

The most obvious way is:

	print -l $filessubject | cat -n

But something like this works too:

	i=0 eval print -l '$((++i))\ '${(q)^filessubject}

If you use 'setopt ksharrays' then change that to $((i++)).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: printing arrays and index
  2005-07-23  4:59 ` Bart Schaefer
@ 2005-07-24  6:46   ` zzapper
  0 siblings, 0 replies; 3+ messages in thread
From: zzapper @ 2005-07-24  6:46 UTC (permalink / raw)
  To: zsh-users

On Sat, 23 Jul 2005 04:59:15 +0000,  wrote:

>On Jul 22,  7:08pm, zzapper wrote:
>} Subject: printing arrays and index
>}
>} I'm using
>} 
>} print -C 1 $filessubject
>
>I was sort of puzzled by why that was suggested.  "print -l" (that's a
>lowercase L, not a one) has the same effect, and works in a lot more
>versions of zsh (the -C option is a very recent addition).
> 
>} I know want to precede each array entry with it's index number 1,2,3, etc
>} 
>} how do?
>
>The most obvious way is:
>
>	print -l $filessubject | cat -n
>
>But something like this works too:
>
>	i=0 eval print -l '$((++i))\ '${(q)^filessubject}
>
>If you use 'setopt ksharrays' then change that to $((i++)).
Thx JWTDO
-- 
zzapper
vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
http://www.rayninfo.co.uk/tips/ vim, zsh & success tips


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-07-24  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-22 18:08 printing arrays and index zzapper
2005-07-23  4:59 ` Bart Schaefer
2005-07-24  6:46   ` zzapper

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).