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

谢谢

最佳答案

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

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

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

10-11 22:23
查看更多