develooper Front page | perl.perl6.users | Postings from May 2020

Re: Raku -npe command line usage

Thread Previous | Thread Next
From:
Andy Bach
Date:
May 8, 2020 20:33
Subject:
Re: Raku -npe command line usage
Message ID:
DM6PR09MB5448E6EA5A205581B820A55EC0A20@DM6PR09MB5448.namprd09.prod.outlook.com
>> raku -e'lines() ==> grep(/^WARN/) ==> sort() ==> join("\n") ==> say()' sample.log
> raku -e'lines() ==> grep(/^WARN/) ==> sort() ==> reduce({$^a ~ "\n" ~ $^b}) ==> say()' sample.log

So what does reduce() do differently than join() here? I was thinking weeding out duplicates but it seems not.

________________________________
From: Fernando Santagata <nando.santagata@gmail.com>
Sent: Friday, May 8, 2020 2:16 PM
To: yary <not.com@gmail.com>
Cc: William Michels <wjm1@caa.columbia.edu>; WFB <wolfgang.banaston@gmail.com>; perl6-users <perl6-users@perl.org>
Subject: Re: Raku -npe command line usage

On Fri, May 8, 2020 at 6:10 PM Fernando Santagata <nando.santagata@gmail.com<mailto:nando.santagata@gmail.com>> wrote:
raku -e'lines() ==> grep(/^WARN/) ==> sort() ==> reduce({$^a ~ "\n" ~ $^b}) ==> say()' sample.log

and the reduce call can be written more compactly: reduce({"$^a\n$^b"})

--
Fernando Santagata

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About