fork(1) download
  1. sqrtEquation :: (RealFloat a, RealFloat b, RealFloat c) => a -> b -> c -> String
  2. sqrtEquation a b c
  3. | d < 0 = "No solutions"
  4. | d == 0 = (show x1)
  5. | d > 0 = (show x1) ++ " and " ++ (show x2)
  6. where d = (b*b - 4*a*c)
  7. x1 = ((-b + sqrt(d))/2*a)
  8. x2 = ((-b - sqrt(d))/2*a)
  9.  
  10.  
  11. main = do
  12. putStr "Input a:"
  13. a <- getLine
  14. putStr "Input b:"
  15. b <- getLine
  16. putStr "Input c:"
  17. c <- getLine
  18. putStrLn result
  19. where result = sqrtEquation a b c
  20.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:19:31: Not in scope: `a'

prog.hs:19:33: Not in scope: `b'

prog.hs:19:35: Not in scope: `c'
stdout
Standard output is empty