我是Haskell的新朋友。 尝试使用foldr函数将一个Ints转换为String的列表或一个Chars的列表,但是我遇到了一个错误。任何想法如何解决?非常感谢。
我的功能:
intToString :: [Int] -> [Char]
intToString = foldr(intToDigit) 0
* Couldn't match type `Char' with `[Char] -> [Char]'
Expected type: Int -> [Char] -> [Char]
Actual type: Int -> Char
* In the first argument of `foldr', namely `(intToDigit)'
In the expression: foldr (intToDigit) 0
In an equation for `intToString':
intToString = foldr (intToDigit) 0
|
100 | intToString = foldr(intToDigit) 0
| ^^^^^^^^^^