Advertisement
ttaaa

Main

Jan 17th, 2022
1,398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Main where
  2.  
  3. import System.Environment
  4.  
  5. import Interpolation
  6. import PointReader
  7. import OutputWriter
  8. import Point
  9.  
  10. mainCycle :: InterpolationType -> Double -> [Point] -> IO ()
  11. mainCycle typ freq p = do
  12.     new_p <- readPoint
  13.     if (isEnd new_p) then
  14.         if (null p) then
  15.             putStrLn "Points wasn't inputed!!!"
  16.         else
  17.             if (isThreaded typ) then do
  18.                 putStrLn "Interpolation done!!!"
  19.                 showPoint (head p)
  20.             else do
  21.                 showInterpolation freq True (createInterpolation typ p)
  22.                 putStrLn "Interpolation done!!!"
  23.     else if (isError new_p) then
  24.         do
  25.             putStrLn "Input format schould be: <Double>; <Double>"
  26.             mainCycle typ freq p
  27.     else
  28.         if ((isThreaded typ) && (not (null p))) then
  29.             do
  30.                 showInterpolation freq False (createInterpolation typ ([head $ p] ++ [getPoint new_p]))
  31.                 mainCycle typ freq ((getPoint new_p) : [])
  32.         else
  33.             mainCycle typ freq (p ++ [getPoint new_p])
  34.  
  35.    
  36.  
  37. main :: IO ()
  38. main = do
  39.     x <- getArgs
  40.  
  41.     let interpolationType = typeFromString $ x !! 0
  42.     let frequency = read $ x !! 1 :: Double
  43.  
  44.     putStrLn . show $ interpolationType
  45.     putStrLn . show $ frequency
  46.  
  47.     mainCycle interpolationType frequency []
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement