开发者

display a list differently Haskell?

hey i was wandering if it was possible to show a list:

["one", "two", "three"]

to be shown as

"one", "two", "three"

need it done for a file

开发者_如何学C

thanks


You can do this with intercalate from Data.List

 showList :: Show a => [a] -> String
 showList = intercalate ", " . map show

The map show converts each element to it's string representation with quotes (and any internal quotes properly escaped), while intercalate ", " inserts commas and spaces between the pieces and glues them together.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜