4
示例代碼:Haskell的類型轉換問題
fac :: Int → Int
fac 0 = 1
fac n = n * fac (n-1)
main = do
putStrLn show fac 10
錯誤:
Couldnt match expected type 'String'
against inferred type 'a -> String'
In the first argument of 'putStrLn', namely 'show'
In the expression: putStrLn show fac 10
+1' $'是你的朋友。 – 2009-12-25 07:43:17
($)和(。)是你愛的朋友<3 – codebliss 2009-12-25 16:42:47