gpt4 book ai didi

list - Haskell 展平字符串列表

转载 作者:行者123 更新时间:2023-12-04 16:30:47 26 4
gpt4 key购买 nike

我想展平字符串列表但有额外的要求。例子
[["My","Name","is"],["John","Doe"]]
输出 :My name is \nJohn Doe
我尝试使用 concat 函数,但仍然没有运气

谢谢

最佳答案

您可以使用 unwords :: [String] -> String 转换 String 的列表s 成单 String ,然后使用 intercalate :: [a] -> [[a]] -> [a] 将行连接在一起,中间有一个分隔符,例如:

tolines :: [[String]] -> String
tolines = intercalate "\n" . map unwords

关于list - Haskell 展平字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57265317/

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