-3
我想在Haskell中編寫一個函數來整數。這是我的代碼:在Haskell中分類時輸入錯誤
div :: Int -> Int -> Double
div a b =a/b
然而,當我嘗試complie它,我總是得到錯誤:
baby.hs:20:10:
Couldn't match expected type ‘Double’ with actual type ‘Int’
In the first argument of ‘(/)’, namely ‘a’
In the expression: a/b
baby.hs:20:12:
Couldn't match expected type ‘Double’ with actual type ‘Int’
In the second argument of ‘(/)’, namely ‘b’
In the expression: a/b
Failed, modules loaded: none.
這裏有一個答案https://stackoverflow.com/questions/35950600/why-it-is-impossible -to-除以整數數在-Haskell中 –