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 24194
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: A way to apply function to each element of an array
- Date: Thu, 29 Aug 2019 13:13:08 +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=lpzLefERUthXZ3THOgM41VbvyZ1OXSUFg5eVYIHNBfA=; b=ODLKQXVkBweg/DfCOa2P7Wu+S/prp9qNEIoLC69sn/eXU6mlDRflQZYrtQVyp1+y0f CHojk7AtoincQTUMoxrF0pM3xx9u80A67I3veU0D6qKOL3eXswUhed8CXyYh+GfjIYEs 8Fjs3GyLXwPpWQEn1p2goUAQhHULba/KOzDudfVYBhlZhiVO5dcxPXHMJM2pdwGodTYd sRvw4oBQzSXEjQQraDEw5U6FPwXSlHwDjkgdPoEBLLTIsl8J0CwiVp9w4DxUoFCSLUES tVel0PSF2Azn2BgYftzyXDgoawaMsF/u5c6CnStPk4baVH2znHsQAApdP0DeqCkh10iz 4r5w==
- In-reply-to: <CAN=4vMpCeYA_udrXj60j2daT7TfU_0aWj0iRRthCti+9YJDj-g@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> <CAN=4vMpCeYA_udrXj60j2daT7TfU_0aWj0iRRthCti+9YJDj-g@mail.gmail.com>
Cool, thanks! It makes the solution much more readable.
czw., 29 sie 2019, 12:47 użytkownik Roman Perepelitsa <
roman.perepelitsa@xxxxxxxxx> napisał:
> 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