Advertisement
vencinachev

HS-Day01

Oct 27th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- hello.hs
  2. main :: IO()
  3. main = do
  4.  putStrLn "Hello, world."
  5.  putStrLn "Hello, from Haskell."
  6.  
  7. -- helloname.hs
  8. main :: IO()
  9. main = do
  10.  putStr "Enter your name: "
  11.  name <- getLine
  12.  putStrLn ("Hello, " ++ name)
  13.  
  14.  
  15. -- myfuncs.hs
  16. f :: Double -> Double
  17. f x = 2*x
  18.  
  19. mysum :: Double -> Double -> Double
  20. mysum a b = a + b
  21.  
  22.  
  23. -- taxi.hs
  24. main :: IO()
  25. main = do
  26.  putStr "Enter distance in km: "
  27.  km_input <- getLine
  28.  let km = read km_input :: Double
  29.  let price = taxiPrice km
  30.  putStrLn ("Taxi price: " ++ (show price))
  31.  
  32.  
  33. taxiPrice :: Double -> Double
  34. taxiPrice x = 2 + 1.2*x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement