develooper Front page | perl.perl6.users | Postings from September 2019

Re: anything faster than say [+] lines?

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
September 28, 2019 11:11
Subject:
Re: anything faster than say [+] lines?
Message ID:
650DAC5A-701B-473C-982F-D3BA1A8735CA@wenzperl.nl


> On 28 Sep 2019, at 10:40, Marc Chantreux <eiro@phear.org> wrote:
> 
> hello,
> 
>> though that works here, admittedly, my p6 is sort old
>> This is Rakudo version 2018.03 built on MoarVM version 2018.03
>> implementing Perl 6.c.
> 
> this lead me test it with the docker rakudo-star (2019.03).
> 
>  time docker run rakudo-star bash -c 'seq 100000000|
>    perl6 -e ''slurp.split("\n")>>.Int.sum.say'''

slurp.lines.map(*.Int).sum.say

should make it a bit faster, at the expense of *much* more memory usage, as opposed to just.

In any case, to get the same result, you could also do

    (0..10_000_00).sum.say

which would come back instantaneously, regardless of the size of the range.

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