Hey。 关于本周的辅导,其中一个问题要求采用其他功能格式Line和格式List编制一个行文清单,从而形成一种功能格式。
我的法典就是这样做的。
type Line = String
formatLine :: Line -> String
formatLine l = l ++ "
"
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
The code seems (to me, at least) like it should work, but instead of creating a new line where " " is, gets appended to the string.
任何帮助都将受到高度赞赏。