0

I am trying to write a haskell function which will calculate the two roots of the quadratic function. I keep getting the error "parse error on input '='. It further says that "perhaps you need a 'let' in a 'do'block.

import Data.List
import System.IO

quad :: (Double, Double, Double) -> (Double, Double)
quad (a, b, c) = (x0, x1)
    where
        d = b * b - (4 * a * c)
        e = - b / (2 * a)
        x0 = e + sqrt d / (2 * a)
        x1 = e - sqrt d / (2 * a)
Alec
  • 31,829
  • 7
  • 67
  • 114
  • The code you have quoted runs fine. I think your error must be somewhere else. – David Whitlock Jan 14 '17 at 08:49
  • 3
    `d` is indented with spaces, `e` is indented by TABs. GHC does not see them aligned on the same column. (GHC should also warn about this, at least newer GHCs do...) – chi Jan 14 '17 at 08:52
  • Interesting. I was given this assignment and have no experience with haskell. So based on some haskell tutorials I banged the code out. Can't seem to get it to run on my end, but perhaps I am trying to run it the wrong way. – RackemW Jan 14 '17 at 17:37

0 Answers0