## Rakudo Progress

I couldn’t be happier with the progress made on Rakudo today. I think we added nearly 2000 passing tests to the test suite — it looks scarily like the April release we might have as many passing tests as “Rakudo Alpha” did when it was retired. (Okay, for the most part I think the new passes are from the hard work of jnthn++, masak++, and moritz++.)

I think a quick look at today’s changes in the reduce metaop `[op]` help illustrate how wonderfully powerful the current Rakudo is. First, moritz and I took the old reduce method and changed it to this:

```our multi sub reducewith(&op, Iterable \$an-iterable,
:\$chaining,
:\$right-assoc,
:\$triangle) {
my \$ai = \$an-iterable.iterator;
\$ai = \$ai.Seq.reverse.iterator if \$right-assoc;

my \$result = \$ai.get;
if \$result ~~ EMPTY {
return &op();
}

if \$chaining {
my \$bool = Bool::True;
my @r = \$bool;
loop {
my \$next = \$ai.get;
last if \$next ~~ EMPTY;
\$bool = \$bool && (\$right-assoc ?? &op(\$next, \$result) !! &op(\$result, \$next));
@r.push(\$bool) if \$triangle;
\$result = \$next;
}
return @r if \$triangle;
return \$bool;
} else {
my @r = \$result;
loop {
my \$next = \$ai.get;
last if \$next ~~ EMPTY;
\$result = \$right-assoc ?? &op(\$next, \$result) !! &op(\$result, \$next);
@r.push(\$result) if \$triangle;
}
return @r if \$triangle;
}
\$result;
}
```

That’s not trivial, but it is very straightforward Perl 6. (I do think it could still use a good code review / refactor.) Then jnthn wired this version into the reduce metaop with a few simple changes to the grammar and actions. (For those of you too lazy too click through, that’s a patch which changed three lines and added three more.)

That may seem simple, but consider that this patch fixes long standing bugs from Rakudo Alpha (heck, even back to Pugs!) and adds significant new functionality Rakudo Alpha never had:

```> say 2 ** 3 ** 4
2.41785163922926e+24
> say [**] 2, 3, 4
2.41785163922926e+24
> say ([\**] 2, 3, 4).perl
[4, 81, 2.41785163922926e+24]
```

Rakudo now makes adding functionality like this downright easy.

Edited to add: mberends++ suggested I should add some more examples, so that inexperienced programmers do not think this is just some fancy way to chain powers. (I used that merely because it is the canonical example of a reduce operation older versions of Perl 6 got wrong.) So without further comment, here are some more examples:

```> say [*] 1..10
3628800
> say ([\*] 1..10).perl
[1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
> say ([=>] 1..10).perl
1 => 2 => 3 => 4 => 5 => 6 => 7 => 8 => 9 => 10
> say ([=>] 1..10).kv.perl
(1, 2 => 3 => 4 => 5 => 6 => 7 => 8 => 9 => 10)
> say ([\~] 'a'..'g').perl
["a", "ab", "abc", "abcd", "abcde", "abcdef", "abcdefg"]
> say ([\R~] 'a'..'g').perl
["a", "ba", "cba", "dcba", "edcba", "fedcba", "gfedcba"]
```