Haskell 防护上的分析错误
您需要在函数定义中使用Haskell 防护上的分析错误,haskell,Haskell,您需要在函数定义中使用=而不是=: haskell.hs:77:2: parse error on input ‘|’ factorial::Int->Int 阶乘0=1 阶乘n |n
=
而不是=
:
haskell.hs:77:2: parse error on input ‘|’
factorial::Int->Int
阶乘0=1
阶乘n
|n<0=错误“无法呼叫否定号码”
|否则=n*阶乘(n-1)
是用于定义事物的语法原子李>=
是用于比较值的函数/运算符=
haskell.hs:77:2: parse error on input ‘|’
factorial :: Int -> Int
factorial 0 = 1
factorial n
| n < 0 = error "Cant call a nagative number"
| otherwise = n * factorial (n-1)