functional programming - Functions in Haskell -
i'm new functional programming. have basic question.
i'm using hugs interpreter,
i write function in haskell; went though several tutorials, i'm not getting it.
fact :: int -> int fact n = if n == 0 1 else n * fact (n-1) this gives me syntax error :-s
error - syntax error in input (unexpected `=')
i assume type right interactive prompt. sadly, these relatively primitive in haskell - complex definitions, such fact, can't entered @ prompt, @ least not in same way you'd write them.
you need put function definitions etc. modules, load via (e.g.) :load fact.hs. there resources hugs provide more information on , other topic (i used http://cvs.haskell.org/hugs/pages/hugsman/index.html check assumptions).
also note indentation matters, code won't work way posted here when in module. tutorials have correct versions. if not, they're useless , should forget them.
Comments
Post a Comment