Advertisement
Guest User

Untitled

a guest
May 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. module Main where
  2.  
  3. count :: [Int] -> Int
  4. count [] = 0
  5. count (a : xs) = (checkA a xs) + count xs
  6.  
  7. checkA :: Int -> [Int] -> Int
  8. checkA _ [] = 0
  9. checkA a (b : xs) = (checkB a b xs) + checkA a xs
  10.  
  11. checkB :: Int -> Int -> [Int] -> Int
  12. checkB _ _ [] = 0
  13. checkB a b (c : xs) = (check a b c) + checkB a b xs
  14. where
  15. check a b c = if (a + b > c) && (a + c > b) && (b + c > a) then 1 else 0
  16.  
  17. main :: IO ()
  18. main = do
  19. print (count l)
  20. where
  21. l = [1, 7, 5, 2, 4]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement