gpt4 book ai didi

list - 以不同的方式显示列表 Haskell?

转载 作者:行者123 更新时间:2023-12-05 00:04:25 25 4
gpt4 key购买 nike

嘿,如果可以显示列表,我正在徘徊:

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

显示为
"one", "two", "three"

需要为文件完成

谢谢

最佳答案

你可以用 intercalate 来做到这一点来自 Data.List

 showList :: Show a => [a] -> String
showList = intercalate ", " . map show
map show将每个元素转换为带引号的字符串表示(以及正确转义的任何内部引号),而 intercalate ", "在片段之间插入逗号和空格并将它们粘合在一起。

关于list - 以不同的方式显示列表 Haskell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5829985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com