Advertisement
KDOXG

lista1

Mar 12th, 2020
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --  lista1.hs
  2. --  Kevin KDOXG
  3. --  Telegram: @kdoxg
  4.  
  5. --  Ex. 1
  6. osQuatroSaoIguais :: Int -> Int -> Int -> Int -> Bool
  7. osQuatroSaoIguais a b c d = (a == b) && (b == c) && (c == d)
  8.  
  9. --  Ex. 2
  10. quantosSaoIguais :: Int -> Int -> Int -> Int
  11. quantosSaoIguais a b c
  12.  | (a == b) && (b == c) = 3
  13.  | ((a == b) && (a /= c)) || ((b == c) && (a /= b)) || ((a == c) && (a /= b)) = 2
  14.  | otherwise = 0
  15.  
  16. --  Ex. 3
  17. todosDiferentes :: Int -> Int -> Int -> Bool
  18. todosDiferentes a b c
  19.  | (a == b) && (b == c) = False
  20.  | ((a == b) && (a /= c)) || ((b == c) && (a /= b)) || ((a == c) && (a /= b)) = False
  21.  | otherwise = True
  22.  
  23. --  Ex. 4
  24. vendas :: Int -> Int
  25. vendas 0 = 16
  26. vendas 1 = 32
  27. vendas 2 = 64
  28. vendas 3 = 128
  29. vendas _ = 69
  30.  
  31. vendaTotal :: Int -> Int
  32. vendaTotal 0 = vendas 0
  33. vendaTotal n = vendas n + vendaTotal (n-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement