Advertisement
vencinachev

Day3FPMain

Nov 8th, 2019
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {-
  2. -- Example 1
  3. main :: IO ()
  4. main = do
  5.  putStr "Please enter your name: "
  6.  name <- getLine
  7.  putStrLn ("Hello, " ++ name ++ ", how are you?")
  8. -}
  9.  
  10. {-
  11. -- Example 2
  12. import Data.Char
  13. main :: IO ()
  14. main = do{
  15.  putStr "Enter a word: ";
  16.  word <- getLine;
  17.  if (isPalindrome word)
  18.   then putStrLn ("\"" ++ word ++ "\" is palindrome!")
  19.   else putStrLn ("\"" ++ word ++ "\"  is not palindrome!") }
  20.  
  21. isPalindrome :: String -> Bool
  22. isPalindrome w = (ys == (reverse ys))
  23.  where ys = map toLower (filter isAlpha w)
  24. -}
  25.  
  26.  
  27. {-
  28. -- Example 3
  29. main :: IO ()
  30. main = do
  31.  putStrLn "What is 2 + 2? "
  32.  x <- readLn
  33.  if x == 4
  34.   then putStrLn "You are right"
  35.   else putStrLn "You are wrong"
  36. -}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement