Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: reduce like iterators

by moritz (Cardinal)
on Jan 03, 2011 at 19:20 UTC ( [id://880243]=note: print w/replies, xml ) Need Help??


in reply to reduce like iterators

I couldn't resist writing a "golfed" Perl 6 version, heavily inspired by functional programming techniques:
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://880243]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-23 17:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found