
8 Aug
2003
8 Aug
'03
9:55 a.m.
Antony Courtney
I often need to format a list of strings using some character as a *seperator* rather than a terminator for the items. Is there some simple combinator or idiom from the Prelude or standard libraries that could be used for this purpose?
List.intersperse :: a -> [a] -> [a]
-- Example: format a list of strings, using a comma as a seperator: mkSepStr :: [String] -> String mkSepStr xs = foldrs (\x s -> x ++ ", " ++ s) "" xs
mkSepStr :: [String] -> String mkSepStr = concat . intersperse ", " Regards, Malcolm