Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A way to apply function to each element of an array
- X-seq: zsh-users 24193
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- Subject: Re: A way to apply function to each element of an array
- Date: Thu, 29 Aug 2019 12:46:53 +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; bh=XFJhGp6B85V5FHLRFJkjNHOQErW5sSbkdPzR2lOhCwA=; b=O0Aag69Ip/M2NXGMVFUx3EqlFGFFGNnuwwRfoHU/DGv27YHU+YKS4ii729BRgL7d3k rF+gStomi54UiukpzZaiQDCqMQxbDY9/UpcCR0YUYT294xpGGr6PyrKYd7uRZihuWLu9 3+rhv4wC6tpVgxRdpebgmcshb4Wui5bVNl8RZlt/Hc2qDdAKk7sQfBA/5uIDZX3cFDGp ut1PEeji2ogu2OGi4GQ7QL3+y8PXntNkC3WgJMJepoL5sXjucASXrzwlrw3XMBcmiYoZ 9QBevjWvcFTOW5frga8tknPtK6ZzNEsJGqPYnKoCtSpHX6lMrFdOUBpcK0ECowXrG3rF GraQ==
- In-reply-to: <CAKc7PVD1Lr-Z1LasY7=kyP5-a7NMZDrWxwJjCgPyX0Axu3UbOw@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: <CAKc7PVD1Lr-Z1LasY7=kyP5-a7NMZDrWxwJjCgPyX0Axu3UbOw@mail.gmail.com>
On Thu, Aug 29, 2019 at 2:51 AM Sebastian Gniazdowski
<sgniazdowski@xxxxxxxxx> wrote:
>
> myarr=( "${(@)${myarr[@]/(#m)*/$(( msfunc(${(q)MATCH}) ))$REPLY}/(#s)0/}" )
I usually use ${foo+} to expand foo for its side effects and to ignore
the substituted value.
myarr=( "${(@)${myarr[@]/(#m)*/${$((msfunc(${(q)MATCH})))+}$REPLY}}" )
This way you can discard the substituted value without knowing what it is.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author