fork download
  1. linefun :: (Double, Double) -> (Double, Double) -> String
  2. linefun (x1, y1) (x2, y2) = "y = " ++ show k ++ " * x + " ++ show b where
  3. k = dy / dx
  4. b = y1 - k * x1
  5. dx = x2 - x1
  6. dy = y2 - y1
  7.  
  8. main = putStrLn $ linefun (0, 1) (1, 3)
Success #stdin #stdout 0s 5756KB
stdin
Standard input is empty
stdout
y = 2.0 * x + 1.0