ttaaa

main haskell

Dec 7th, 2021
700
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Main where
  2.  
  3. import Fib
  4. import Powers
  5. import Data.Time ( diffUTCTime, getCurrentTime )
  6.  
  7. fibsN :: Int
  8. fibsN = 40
  9.  
  10. powersN :: Int
  11. powersN = 100
  12.  
  13. main :: IO ()
  14. main = do {
  15.     putStrLn ("Fibs solutions for n=" ++ show fibsN)
  16.     ; print (byZipWithFibs fibsN)
  17.  
  18.     ; putStr "Simple recursion answer: "
  19.     ; begT_1 <- getCurrentTime
  20.     ; print (sum (filter even (simpleRecursionFibs fibsN)))
  21.     ; endT_1 <- getCurrentTime
  22.     ; putStrLn ("Time: " ++ show (diffUTCTime endT_1 begT_1))
  23.  
  24.     ; putStr "Tail recursion answer: "    
  25.     ; begT_2 <- getCurrentTime
  26.     ; print (sum (filter even (tailRecursionFibs fibsN)))
  27.     ; endT_2 <- getCurrentTime
  28.     ; putStrLn ("Time: " ++ show (diffUTCTime endT_2 begT_2))
  29.  
  30.     ; putStr "ZipWith solution answer: "
  31.     ; begT_3 <- getCurrentTime
  32.     ; print (sum (filter even (byZipWithFibs fibsN)))
  33.     ; endT_3 <- getCurrentTime
  34.     ; putStrLn ("Time: " ++ show (diffUTCTime endT_3 begT_3))
  35.  
  36.     ; putStr "Simple iterate answer: "
  37.     ; begT_4 <- getCurrentTime
  38.     ; print (sum (filter even (simpleIterateFibs fibsN)))
  39.     ; endT_4 <- getCurrentTime
  40.     ; putStrLn ("Time: " ++ show (diffUTCTime endT_4 begT_4))
  41.  
  42.     ; print [diffUTCTime endT_1 begT_1, diffUTCTime endT_2 begT_2, diffUTCTime endT_3 begT_3, diffUTCTime endT_4 begT_4]
  43.  
  44.     ; putStrLn ("Powers solutions for n=" ++ show powersN)
  45.     ; putStr "Simple powers solution answer: "
  46.     ; begT_5 <- getCurrentTime
  47.     ; putStrLn (show (powersSimpleSolution powersN))
  48.     ; endT_5 <- getCurrentTime
  49.     ; putStrLn ("Time: " ++ show (diffUTCTime endT_5 begT_5))
  50.    
  51. }
RAW Paste Data