rootFunction :: Float -> Float -> Float -> Int
rootFunction a b c
| a == 0 = dRoots a b c
| otherwise = numberNDroots a b c
numberNDroots :: Float -> Float -> Float -> Int
numberNDroots a b c
| b^2 > (4.0*a*c) = 2
| b^2 == (4.0*a*c) = 1
| b^2 < (4.0*a*c) = 0
dRoots :: Float -> Float -> Float -> Int
dRoots a b c
| b /= 0 = 1
| b == 0 && c /= 0 = 0
| b == 0 && c == 0 = 3
No comments:
Post a Comment