On 1/13/06, Sebastian Sylvan <[EMAIL PROTECTED]> wrote:
> blocks = map concat . groupBy (const (not . null)) . lines

Thanks.  That's a little more involved than I was looking for, but that
certainly looks better than pattern matching on ('\n':'\n':rest).  ;-)

For the record, lines removes the trailing newline, so a string like:

    a
    b

    c
    d

becomes ["ab", "cd"], which can interfere with processing if the whitespace
is significant.  Changing this to

   blocks = map unlines . groupBy (const (not . null)) . lines

re-adds all of the newlines, thus re-adding the significant whitespace,
while still chunking everything into blocks:   ["a\nb\n","\nc\nd\n"]

Thanks again,

-- Adam
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to