2
如何使用foldl'將列表轉換爲帶分隔符「|」的字符串?Haskell將字符串列表轉換爲帶分隔符的字符串「|」
ltos :: String -> [String] -> String
ltos [] = ""
ltos (m:n) = foldl' f acc xs
where
f a b =
acc =
xs =
例如,
ltos ["a", "b", "c"]
將輸出
"a|b|c"
'Data.List.intercalate「|」' – user2407038