The following algorithm is supposed to calculate the 2nd degree equation root, but compiling it produces a compiling error.
I copied it from a tutorial.
2 roota.hs:5:20: parse error on input `='
roots (a,b,c) =
if d < 0 then error "sorry" else (x1, x2)
where x1 = e + sqrt d / (2 * a)
x2 = e - sqrt d / (2 * a)
d = b * b - 4 * a * c
e = - b / (2 *a)
Thanks for the answers.
It’s a problem with indentation. Try
See also a question about indentation and and an article from a Haskell Wikibook.