Changing the name is not just about changing our comparison to Perl 6. It is about signaling to people both outside and inside the echo chamber that we are willing to move forward. That we want to move forward.

pumpkin presents the best option I've seen for an answer to that. It doesn't solve every problem, but it solves enough. It gives us the room to grow into whatever we want to be.

]]>However, I think the raptor meme belongs to the perl5+CPAN platform rather than to perl5 the language itself, so I chose not to try and force it onto the language.

]]>use List::Util qw(sum0); my $sum = sum0 map { my $n = int($max/abs $_); $n * ($n+1) * $_/2 } qw/ 3 5 -15 /;

We find the number `$n`

of multiples of 3 below `$max`

. Then do the triangular number thing (`$n * ($n+1) / 2`

) and multiply that by 3 to scale it up correctly. Then we do the same for 5. Then, because we've double counted multiples of 15, we do the same for 15 and subtract it.

Overall this solution is **O(1)** rather than **O( n)** because we don't need to loop through an increasingly long list of numbers. We can calculate

`$max=10_000_000`

in roughly the same time it takes to calculate `$max=10`

.Here's a version that is more idiomatic, faster, and gives the right same answer as the perl5 examples (the difference seems to be that the perl6 example above included "20", while p5 variants excluded it.)

use v6;sub MAIN($max = 1000) {

my @threes = 3, 6, 9 ... * >= $max;

my @fives = 5, 10, 15 ... * >= $max;# combine the series, order, eliminate dupes, remove any trailing high elements.

my @multiples = (@threes, @fives).sort.squish.grep({$_say "My multiples are: ", @multiples;

say "total: {[+] @multiples}";

}

time shows:

$ time perl6-p foo.p6 20 My multiples are: 3 5 6 9 10 12 15 18 total: 78real 0m0.921s

user 0m0.780s

sys 0m0.139s

Compared to your first example above, my local timings with perl 5.16:

real 0m0.084s user 0m0.076s sys 0m0.008s

That brings it down to about 10x slower instead of 75x.

]]>use v6;]]>sub MAIN($max = 1000) {

my @threes = 3, 6, 9 ... * >= $max;

my @fives = 5, 10, 15 ... * >= $max;my @multiples = (@threes, @fives)\

.sort.squish.grep({$_# Print multiples and the total.

say "My multiples are: ", @multiples;say "total: {[+] @multiples}";

}

$ perl6 --version

This is perl6 version 2013.09 built on parrot 5.5.0 revision 0

$ sysctl -a | grep machdep.cpu.brand.string

machdep.cpu.brand_string: Intel(R) Core(TM) i5-2557M CPU @ 1.70GHz

$ time perl6 stuff.p6

My multiples are: 3 5 6 9 10 12 15 18 20 21 24 25 27 30 33 35 36 ... *snip* ... 993 995 996 999

Total: 233168

real 0m1.289s

user 0m1.037s

sys 0m0.220s

real 0m0.064s

user 0m0.010s

sys 0m0.015s

So my Mac has a slower time for the Perl 5 code so I'd imagine the OP would have a slightly better time than 1s for the Perl 6 code running in the latest R* parrot build?

]]>sub MAIN( Int $max = 1000 )instead, you'll even get a helpful error message if the user writes "over nine thousand" instead of a number.

Also, for interpolating arrays into strings, you can also just write

"My multiples are: @multiples[]".say;

And another thing: I think "1 ..^ $max" looks prettier than "1 .. $max-1".

]]>unless any(@multiples) $start {

That looks like TTIAR (two terms in a row) to me (syntax error).

]]>`for`

loop has 3 levels of signature unpacking. You don't see the first one which is implicit.]]>