Advertisement
ttaaa

OutputWriter

Jan 17th, 2022
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module OutputWriter
  2.     (
  3.         showInterpolation,
  4.         showPoint
  5.     ) where
  6.  
  7. import Interpolation
  8. import Point
  9.  
  10. showInterpolation :: Double -> Bool -> Interpolation -> IO ()
  11. showInterpolation frequency flag i = foldr (>>) (return ()) (map (showPoint . interpolate i) (genFractional frequency (getL i) (getR i) flag))
  12.  
  13. showPoint :: Point -> IO ()
  14. showPoint p = putStrLn ("" ++ (show . getX $ p) ++ "; " ++ (show . getY $ p))
  15.  
  16. genFractional :: Double -> Double -> Double -> Bool -> [Double]
  17. genFractional 0 _ _ _ = error "Frequency must be more then 0"
  18. genFractional frequency l r flag = do
  19.     if (l >= r) then
  20.         [r]
  21.     else if ((r >= l + frequency) || flag) then
  22.         [l] ++ genFractional frequency (l + frequency) r flag
  23.     else []
  24.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement