Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: How to add string to end of each array element without loops



> On Mar 25, 11:32pm, nix@xxxxxxxxxxxxxxxx wrote:
> } Subject: How to add string to end of each array element without loops
> }
> } a=(1 2 3)
> } a=(foo$^a[@])
> }
> } print -l "${(@n)a}"
>
> If $^a[@] works, then you don't need the subscript, either:
>
> a=(foo$^a)
>
> Futhermore you don't need the quotes and (@) in the print expression:
>
> print -l ${(n)a}
>
> } foo1
> } foo2
> } foo3
> }
> } I would like to get the following output instead:
> }
> } 1foo
> } 2foo
> } 3foo
>
> I'm not understanding what you're asking.  Either this is as easy as
>
>     a=(1 2 3)
>     a=(${^a}foo)  # braces needed to distinguish $a from $afoo
>
> or you've already got (foo$^a) and you're asking how to change "foo?"
> into "?foo" for the whole array
>
>     setopt extendedglob
>     a=(${a/(#b)foo(<->)/$match[1]foo})
>
> or you mean something else entirely.  Can you elaborate?
>
> --
>

10.0.0.1 	10.127.255.254

> On 25 March 2011 22:32,  <nix@xxxxxxxxxxxxxxxx> wrote:
>> a=(1 2 3)
>> a=(foo$^a[@])
>>
>> print -l "${(@n)a}"
>>
>> foo1
>> foo2
>> foo3
>>
>> I would like to get the following output instead:
>>
>> 1foo
>> 2foo
>> 3foo
>
> a=(${^a}foo) ?
>
> --
> Mikael Magnusson
>

I wanted to append word 'foo' to end of each element in an array and
Mikael's solution did it.

Now however, im getting a segfault when an array elements exceeds over 4
million elements even there are enough RAM in my box.

Is there a way to increase this limit? There was nothing to that with
'limit' command.









Messages sorted by: Reverse Date, Date, Thread, Author