idiom for producing comma-seperated lists?

Antony Courtney antony@apocalypse.org
Fri, 08 Aug 2003 10:01:42 -0400


Ketil Z. Malde wrote:
> Antony Courtney <antony@apocalypse.org> writes:
> 
> 
>>-- Example: format a list of strings, using a comma as a seperator:
>>mkSepStr :: [String] -> String
>>mkSepStr xs = foldrs (\x s -> x ++ ", " ++ s) "" xs
>>
>>t0 = mkSepStr []                   -- ==> ""
>>t1 = mkSepStr ["hello"]            -- ==> "hello"
>>t2 = mkSepStr ["10","20","30"]     -- ==> "10, 20, 30"
>>
>>What do the rest of you do to solve this particular problem?
> 
> 
> Uh, concat and intersperse?
> 

Yep, that'll do the trick.

Thanks for all the lightnin-fast responses.  Appologies for overlooking 
this!

	-antony

-- 
Antony Courtney
Grad. Student, Dept. of Computer Science, Yale University
antony@apocalypse.org          http://www.apocalypse.org/pub/u/antony