haskell - Parse error on guards -


factorial :: int -> int   factorial 0 = 1  factorial n     | n < 0 == error "cant call nagative number"    | otherwise = n * factorial (n-1) 

can explain why getting error?

haskell.hs:77:2: parse error on input ‘|’ 

you need use = not == in function definition:

factorial :: int -> int  factorial 0 = 1 factorial n     | n < 0     = error "cant call nagative number"    | otherwise = n * factorial (n-1) 
  • = syntactic atom used defining things;
  • == function/operator used comparing values.

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -