Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Filtering array on index
- X-seq: zsh-users 24088
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- Subject: Re: Filtering array on index
- Date: Tue, 23 Jul 2019 05:38:39 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- 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==
- In-reply-to: <CABZhJg80vQuMHGKABkzR1bdtt89Akpkfd8kWOV83N-qvqioaXw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg80vQuMHGKABkzR1bdtt89Akpkfd8kWOV83N-qvqioaXw@mail.gmail.com>
On Thu, 25 Oct 2018 at 13:30, Jesper Nygårds <jesper.nygards@xxxxxxxxx> wrote:
>
> I have an array which is the result of using zparseopts on a specification
> that makes it possible to specify several filters with a -v flag. The
> resulting array might look like the following:
>
> myarr=(-v filter1 -v filter2)
I've recently had this problem. One other way to do it:
~ idx=0; olen=$#a+1; a=( ${a[@]/(#m)*/$a[$(( ++idx % 2 ? olen : idx ))]} )
~ print -rl -- $a
filter1
filter2
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author