Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by tadman (Prior)
on Sep 11, 2007 at 03:44 UTC ( #638214=note: print w/ replies, xml ) Need Help??


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

My take on a slightly more concise Ruby version:

s = "ZBBBCZZ" x = s.scan(/((.)\2*)/).map{|v|v[0]}


Comment on Re: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
Download Code
Re^2: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
by Anonymous Monk on Sep 11, 2007 at 08:20 UTC
    Generic version in the D programming language
    $ cat test4.d && gdc test4.d -o test4 && echo "----" && ./test4 import std.stdio; T[][] group(T)(T[] array) { T[][] res; foreach (index, elem; array) { if (index == 0 || elem != array[index-1]) res~=(T[]).init; res[$-1]~=elem; } return res; } void main() { writefln(group("ZBBBCZZ")); } ---- [Z,BBB,C,ZZ]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-09-17 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (54 votes), past polls