[Haskell-cafe] Re: Reversing a string of words: C# v Perl V Ruby
v Haskell
Yitz Gale
gale at sefer.org
Tue Dec 12 21:54:28 EST 2006
Brandon S. Allbery KF8NH writes:
> Off the top of my head, the C++ one translates to:
>
> *Main> concatMap reverse . groupBy (\l r -> (l == ' ') == (r == '
> ')) . reverse $ "one two three four "
> " four three two one"
>
> There are almost certainly more idiomatic ways to do it, but I'm
> still learning.
Nice. Here is something similar:
reverseWords = concat . reverse . groupBy eqsp
where eqsp x y = isSpace x == isSpace y
Regards,
Yitz
_._ .._. ___.. _. .... _.. . .__ _... ___.. ... _. _._
More information about the Haskell-Cafe
mailing list