[Haskell-cafe] Re: Reversing a string of words: C# v Perl V Ruby v Haskell

Ulf Norell ulfn at cs.chalmers.se
Wed Dec 13 04:23:25 EST 2006


On Dec 13, 2006, at 3:54 AM, Yitz Gale wrote:

> Nice. Here is something similar:
>
> reverseWords = concat . reverse . groupBy eqsp
>   where eqsp x y = isSpace x == isSpace y

This can be made even nicer using the 'on' function [1]:

reverseWords = concat . reverse . groupBy ((==) `on` isSpace)

[1] http://www.haskell.org/pipermail/libraries/2006-November/006156.html

/ Ulf





More information about the Haskell-Cafe mailing list