zsh-users
 help / color / mirror / code / Atom feed
* prepend to array?
@ 2017-06-27  2:43 Anthony Heading
  2017-06-27  3:14 ` Daniel Shahaf
  0 siblings, 1 reply; 2+ messages in thread
From: Anthony Heading @ 2017-06-27  2:43 UTC (permalink / raw)
  To: zsh-users

Hi,

I've often found myself wanting to do this:

% zsh -c 'x=(a b c); x[0]+=(vip); echo $x'
zsh:1: x: assignment to invalid subscript range

I eventually realized I could write it this way instead:

% zsh -c 'x=(a b c); x[-999999]+=(vip); echo $x'
vip a b c

Is there any more elegant way to prepend?

Anthony


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

* Re: prepend to array?
  2017-06-27  2:43 prepend to array? Anthony Heading
@ 2017-06-27  3:14 ` Daniel Shahaf
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Shahaf @ 2017-06-27  3:14 UTC (permalink / raw)
  To: Anthony Heading, zsh-users

Anthony Heading wrote on Mon, 26 Jun 2017 22:43 -0400:
> % zsh -c 'x=(a b c); x[-999999]+=(vip); echo $x'
> vip a b c
> 
> Is there any more elegant way to prepend?

x[1,0]=(vip)


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

end of thread, other threads:[~2017-06-27  3:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27  2:43 prepend to array? Anthony Heading
2017-06-27  3:14 ` Daniel Shahaf

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