From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5a3c69ad for ; Tue, 23 Jul 2019 03:39:35 +0000 (UTC) Received: (qmail 6575 invoked by alias); 23 Jul 2019 03:39:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24088 Received: (qmail 4453 invoked by uid 1010); 23 Jul 2019 03:39:26 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua1-f49.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25517. spamassassin: 3.4.2. Clear:RC:0(209.85.222.49):SA:0(-2.0/5.0):. Processed in 2.370043 secs); 23 Jul 2019 03:39:26 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.222.49 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ZErOzVCWtSIP3YbqZ+KqxixK+u2s0dXL+i8AWzBjolY=; b=eSHPfJ9GNHFWHZD4sa9OgT7nwjxeGqGnT4+un7k2/OhmS/J5eUslDn7LkQbFcJFG6I Xpk8bBpx+pQmjZKHn2kYl56++KMjjh0Vq14UbcCTyTYEZ4+snN4ruPU46h/aG6hfkFTs Ylq9h7fxbpjaJOF1JZdW1f1DTRBDPk33EUVpMslL7zMDQe2aCXlRgCHCpWPS7AtY842E 32G1CLrwJ0MG2oBOYvYSuRij75g6XOvR/R+7roMKDpRjFJ+lEd2LlE2Kk728BT+AtprQ dprqsDKWfgyE8cu5+ec+NMrxZAAIXJ1svRm1f2M1WSdS2Gdko3k5RS7xS6z3PwOERznU gzag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ZErOzVCWtSIP3YbqZ+KqxixK+u2s0dXL+i8AWzBjolY=; b=nZG8IEbReJsy+PviMz9oGA0gwPUTSawhlCRsZ5Rqlv5PKI9HxwOv4YeVwoizjwdWh+ F0BSDMvutqfeZ2WUXLlKq2981nntDZsFeMzLd97n5v3PJLYHg0L/9olLUBBenECLO13a em3bBCfeTY46rGawUnjewWh5HhoJJ5WmUqz27QufqcL8tVilg2f23g/i92lA6ASAKaKx K/3gQCLZmQq987rSd3lnCqCv9ImCFCyQ0t80Bv0uNkvA3ARzEomYnLBKaD0T58lGay4O J4gxFEsDLdwtfpkMRGCq8aZG8dy0vALaJBMM7kNbmV4N73fZyK8zBvHtCefGyqJVY0pd CJtg== X-Gm-Message-State: APjAAAWB96U0f/F4AdtOXomuxMZRxQZBQ2xt/sRpG7iEeq2wPsEToDN/ 2mmStEZ+ueqtgx9xhhZ20xdRO1ytG95x3OSBisWUql0I+RQ= X-Google-Smtp-Source: APXvYqxHEWlP1xf+2ZESfOQONzLSYr3+Qu2BXpIHZ1L2kbIEkCwn3juhSPiLunqO20Q2ygdISczZxsKO6gBgwm1Taog= X-Received: by 2002:ab0:748a:: with SMTP id n10mr15922664uap.82.1563853130745; Mon, 22 Jul 2019 20:38:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Tue, 23 Jul 2019 05:38:39 +0200 Message-ID: Subject: Re: Filtering array on index To: =?UTF-8?Q?Jesper_Nyg=C3=A5rds?= Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 25 Oct 2018 at 13:30, Jesper Nyg=C3=A5rds wrote: > > I have an array which is the result of using zparseopts on a specificatio= n > that makes it possible to specify several filters with a -v flag. The > resulting array might look like the following: > > myarr=3D(-v filter1 -v filter2) I've recently had this problem. One other way to do it: ~ idx=3D0; olen=3D$#a+1; a=3D( ${a[@]/(#m)*/$a[$(( ++idx % 2 ? olen : idx )= )]} ) ~ print -rl -- $a filter1 filter2 --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org