晚報,Haskell的錯誤 - 更PARAMATERS比需要
我具備的功能
partialDecode :: [(Char, Char)] -> String -> String
partialDecode [] y = y -- If we have gone through all guesses we may return the string
partialDecode x y = partialDecode (drop 1 x) replace ((fst (x !! 0) snd (x !! 0) y)) -- Recurse over the function: Drop the leading element in the list of guesses and substitute every occurrence of the guess in the string
然而,當我運行ghci中返回一個錯誤說遞歸時,我提供3個paramters而不是2。我不確定這是什麼意思,我提供了一個元組清單(drop 1 x)和一個替換字符串((fst(x !! 0)snd(x !! 0)y))
建議?
乾杯!
你應該閱讀錯誤消息更密切,他們攜帶有用的信息。當然關於「3個參數而不是2個」的錯誤也提到了*哪個函數被調用的參數個數錯誤。 – duplode
另一個提示:x !! 0通常寫爲頭x。 –