Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)

by eyepopslikeamosquito (Chancellor)
on Sep 13, 2007 at 02:53 UTC ( #638725=note: print w/replies, xml ) Need Help??


in reply to Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)

For cheap thrills, a Perl 5 version using reduce:

use List::Util qw(reduce); my $s = "ZBBBCZZ"; my $x = reduce { if (@$a && index($a->[-1], $b) >= 0) { $a->[-1] .= $b + } else { push @$a, $b } $a } [], split //, $s;

  • Comment on Re: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
  • Download Code

Replies are listed 'Best First'.
Re^2: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
by Anonymous Monk on Sep 18, 2007 at 10:18 UTC
    I like the scan/map solution of ruby but I must admit too, that the javascript solution comes out cleanest :) "ZBBBCZZ".match(/((.)\2*)/g)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2016-09-25 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (466 votes). Check out past polls.