0

我正在编写这段代码,我需要取消一个函数,以便它允许元组值输入。这是我的代码:

printField :: Int -> String -> String
--the function to be uncurried

printRow :: [(Int, String)] -> String
printRow d = map (uncurry printField) d

但这给我带来了以下错误,我不知道为什么:

Couldn't match type '[Char]' with 'Char'
Expected type: Int -> String -> Char
  Actual type: Int -> String -> String
In the first argument of 'uncurry', namely 'printField'
In the first argument of 'map', namely '<uncurry printField>'
In the expression: map <uncurry printField> d

有谁知道这意味着什么以及如何解决它?

提前致谢!

最好的问候, Skyfe。

4

1 回答 1

2

正如 Satvik 已经提到的,使用concatMap.

你可以在这里使用 eta 减少并删除冗余d

printRow = concatMap (uncurry printField)

于 2013-09-29T13:35:56.243 回答