Roots of a quadratic function: Difference between revisions
Content deleted Content added
MaiconSoft (talk | contribs) m Added Delphi reference to Pascal code |
m →{{header|Haskell}}: Tidied, applying Ormolu. |
||
Line 998:
quadraticRoots :: (CD, CD, CD) -> (CD, CD)
quadraticRoots (a, b, c)
)
| otherwise =
( (- b + d) / (2 * a),
(2 * c) / (- b + d)
)
where
d = sqrt $ b ^ 2 - 4 * a * c
Line 1,009 ⟶ 1,014:
mapM_
(print . quadraticRoots)
[ (3, 4, 4 / 3),
(3, 2, -1),
(3, 2, 1),
(1, -10e5, 1),
(1, -10e9, 1)
]</lang>
{{Out}}
<pre>((-0.6666666666666666) :+ 0.0,(-0.6666666666666666) :+ 0.0)
|