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

Re: selecting elements in array



On Thu, 21 Apr 2005 13:43:55 +1000, Wataru Kagawa <wkagawa@xxxxxxxxxxxxxxxxxxxx> wrote:

Hi all,

How do I select elements with indices that are multiples of 3, in an array? For example, I have,

list=( 123 native Terminal 456 native Excel 789 native X11 )

and would like to select,

Terminal Excel X11

for i in {1..3}; do
print $list[$(($i*3))]
done

or build a new array:

new=()
for i in {1..3}; do
new+=( $list[$(($i*3))] )
done

-Eric


for compadd.  Help is much appreciated.

Wataru Kagawa





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