nuky
03-19-2004, 06:30 AM
Hi,
I know this query is probably a very basic one but I am a beginner and am trying my best with online tutorials.
I am trying to compile the following code which finds the roots of a quadratic equation (ax^2 + bx + c):
roots :: (Float, Float, Float) -> (Float, Float)
roots (a, b, c)
|(a == 0) = error "n"
|(d < 0) = error "c"
| otherwise ((-b-r)/e, (-b+r)/e)
where { d= b * b - 4 * a * c;
r = sqrt d;
e = 2 * a }
But I am getting the following error at line 6:
Syntax error in declaration (unexpected keyword "where").
Please can anyone tll me what's wrong with this code. I have looked up several online tutorials and from what I can figure I have used the "where" clause correctly.
Any help would be GREATLY appreciated! :)
I know this query is probably a very basic one but I am a beginner and am trying my best with online tutorials.
I am trying to compile the following code which finds the roots of a quadratic equation (ax^2 + bx + c):
roots :: (Float, Float, Float) -> (Float, Float)
roots (a, b, c)
|(a == 0) = error "n"
|(d < 0) = error "c"
| otherwise ((-b-r)/e, (-b+r)/e)
where { d= b * b - 4 * a * c;
r = sqrt d;
e = 2 * a }
But I am getting the following error at line 6:
Syntax error in declaration (unexpected keyword "where").
Please can anyone tll me what's wrong with this code. I have looked up several online tutorials and from what I can figure I have used the "where" clause correctly.
Any help would be GREATLY appreciated! :)