sub compress(*@a) { flat @a Zxx 1, (@a Zne @a[1..*-1]) } say compress(<a a a a b c c a a d e e e e>).perl;
The *-1 is a workaround for a rakudo bug, in a perfect Perl 6 implementation 1..* would work too.
In reply to Re: reduce like iterators
by moritz
in thread reduce like iterators
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |