From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14692 invoked from network); 21 Apr 2005 07:34:46 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Apr 2005 07:34:46 -0000 Received: (qmail 60499 invoked from network); 21 Apr 2005 07:34:39 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Apr 2005 07:34:39 -0000 Received: (qmail 16151 invoked by alias); 21 Apr 2005 07:34:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8726 Received: (qmail 16137 invoked from network); 21 Apr 2005 07:34:29 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Apr 2005 07:34:29 -0000 Received: (qmail 59488 invoked from network); 21 Apr 2005 07:34:29 -0000 Received: from vms048pub.verizon.net (206.46.252.48) by a.mx.sunsite.dk with SMTP; 21 Apr 2005 07:34:18 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IFA00DDSD14Y4T3@vms048.mailsrvcs.net> for zsh-users@sunsite.dk; Thu, 21 Apr 2005 02:34:17 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j3L7YFb3001948 for ; Thu, 21 Apr 2005 00:34:15 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j3L7YFah001947 for zsh-users@sunsite.dk; Thu, 21 Apr 2005 00:34:15 -0700 Date: Thu, 21 Apr 2005 07:34:15 +0000 From: Bart Schaefer Subject: Re: selecting elements in array In-reply-to: To: zsh-users@sunsite.dk Message-id: <1050421073415.ZM1946@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <1830d300995f75ea6076d5d38133c886@jota.gsc.riken.go.jp> Comments: In reply to "Eric Mangold" "Re: selecting elements in array" (Apr 21, 4:06pm) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Apr 21, 4:06pm, Eric Mangold wrote: } Subject: Re: selecting elements in array } } On Thu, 21 Apr 2005 13:43:55 +1000, Wataru Kagawa } wrote: } } > How do I select elements with indices that are multiples of 3, in an } > array? [...] for compadd. Help is much appreciated. } } for i in {1..3}; do } print $list[$(($i*3))] } done Right, except replace "print" with "compadd", and you don't need the $(( )) because the stuff in the [ ] is already treated as arithmetic. for i in {1..3}; do compadd $list[i*3]; done or for ((i=3; $+list[i]; i+=3)); do compadd $list[i]; done or any of a number of other ways. There's not, however, a way to write a single subscript parameter expansion that picks out non-contiguous array slices.