Advertisement
DimasDark

AAAA

Oct 29th, 2014
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- | Main entry point to the application.
  2. module Main where
  3.  
  4. gerarListaCombinacoes :: Int -> Int -> [[Int]]
  5. gerarListaCombinacoes n 0 = [[]]
  6. gerarListaCombinacoes n k | n < k = [[]]
  7.                           |otherwise =  [(x:xs) | x <- [0..n-1], xs <- (gerarListaCombinacoes n (k-1)), x <= (head xs)]
  8.  
  9. filtraCombinacoes :: [[Int]] ->[[Int]]
  10. filtraCombinacoes (l:ls) = [filtraPares l ] ++ filtraCombinacoes ls
  11.  
  12. filtraPares :: [Int] -> [Int]
  13. filtraPares [] = []
  14.  
  15.  
  16.  
  17. main :: IO()
  18. main = do
  19.          print $ gerarListaCombinacoes 4 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement