On 2006-01-13 at 13:32PST Jared Updike wrote:
> That works except it loses single newline characters.
>
> let s = "1234\n5678\n\nabcdefghijklmnopq\n\n,,.,.,."
> Prelude> blocks s
> ["12345678","abcdefghijklmnopq",",,.,.,."]
Also the argument to groupBy ought to be some sort of
equivalence relation.
blocks = map unlines
. filter (all $ not . null)
. groupBy (\a b -> not (null b|| null a))
. lines
... but that suffers from the somewhat questionable
properties of lines and unlines.
--
Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe