I thought I'd try my hand at a more idiomatic Perl 6 version. Here's my first attempt:
((100..999) X (100..999)).map({$^a * $^b}).grep({$_ eq $_.flip}).max.say
Unfortunately, the usual caveats apply. This blows up the current Rakudo, no doubt because without lazy lists it tries to construct a huge list entirely in memory and then collapses. Rakudo ng has lazy lists, but it doesn't have grep or max yet. So for now, this is purely a hypothetical implementation.
However, with any luck, Rakudo ng will handle this by the end of the week...
ng is also lacking X and flip, on further inspection. But it does have a first stab at map and say.
ReplyDeleteSweet, glad to hear about rakudo progress and I'm very glad that euler_bench has been helpful. Though to give credit where credit is due, it looks like @leto's work (http://github.com/notbenh/euler_bench/commits/master/perl6/004/01.pl).
ReplyDelete