[Haskell-cafe] Using ShowS or Difference Lists
Felipe Lessa
felipe.lessa at gmail.com
Sat Feb 6 08:17:28 EST 2010
On Sat, Feb 06, 2010 at 11:12:40PM +1030, Mark Spezzano wrote:
> -- Function: joinLines
> -- Joins the Words within Lines together with whitespace and newline characters
> -- Argument: Lines to pad with whitespace and newlines
> -- Evaluate: The processed and concatenated String
> joinLines :: [Line] -> String
> joinLines (l:[]) = concat (intersperse " " l)
> joinLines (l:ls) = (concat (intersperse " " l)) ++ ('\n':joinLines ls)
Why not just
joinLines = unlines . map unwords
This should be as fast as you may get using lists of lists of
lists of Chars :).
--
Felipe.
More information about the Haskell-Cafe
mailing list