I really dont like the regex magic of the ruby solution, cant you guys think of another solution :-)How about some inject magic?
x = s.split(//).inject([]) {|a,e| (a.last && a.last[e] ? a.last : a) < +< e; a}
In reply to Re^3: Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
by eyepopslikeamosquito
in thread Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)
by eyepopslikeamosquito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |