我应该编写一个函数来执行标题建议的操作。但是,我正在努力解决一些错误,我在我的代码中找不到错误。这是我到目前为止所拥有的:
import Data.Char
maxWord word = maxWord_h word 0 0
maxWord_h word currVal maxx
| word == [] = maxOf (currVal maxx)
| isAlpha (head word) = maxWord_h ((tail word) (currVal + 1) maxx)
| otherwise = maxWord_h (tail word) 0 (maxOf (currVal maxx))
maxOf a b
| a > b = a
| otherwise = b
和错误:
Couldn't match expected type `((a0 -> a0) -> a0)
-> (a0 -> a0) -> [Char]'
with actual type `[Char]'
The function `tail' is applied to three arguments,
but its type `[Char] -> [Char]' has only one
In the first argument of `maxord_h', namely
`((tail ord) (currVal + 1) maxx)'
In the expression: maxord_h ((tail ord) (currVal + 1) maxx)
如果有人能为我指出错误并解释它们,我将不胜感激。我是函数式编程的初学者,所以要温柔。