
13 Jan
2006
13 Jan
'06
4:47 p.m.
On 1/13/06, Sebastian Sylvan
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