嘿。對於本週的教程,其中一個問題要求通過使用其他函數formatLine和formatList來創建函數formatLines,以格式化行列表。新線Haskell
我的代碼看起來像這樣;
type Line = String
formatLine :: Line -> String
formatLine l = l ++ "\n"
formatList :: (a -> String) -> [a] -> String
formatList f [] = []
formatList f xs = f (head xs) ++ formatList f (tail xs)
formatLines :: [Line] -> String
formatLines xs = formatList formatLine xs
代碼似乎(對我來說,至少)像它應該工作,但是,而不是創建一個新的行,其中「\ n」是,\ n增加附加到字符串。
任何幫助將不勝感激。
'formatList = map' – Chuck