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