Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- safeDivision :: Double -> Double -> Maybe Double
- safeDivision x 0 = Nothing
- safeDivision x y = Just (x / y)
- data Nst = Zero (Maybe Double) | One (Maybe Double) | Two (Maybe (Double, Double)) deriving Show
- nullstellen :: Double -> Double -> Double -> Nst
- nullstellen a b c = let z = dfun a b c in if (z < 0) then Zero (Nothing) else if (z == 0) then One (Just (-b/(2*a))) else Two (Just ((-b+sqrt(z)/(2*a)), (-b-sqrt(z)/(2*a))))
- dfun a b c = (b^2 - (4 * a * c))
Add Comment
Please, Sign In to add comment