Created
June 30, 2016 21:18
-
-
Save ThomasCrevoisier/da7b0915188e4cdf0023a035fda22be7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Yolo where | |
combinaisons :: [Int] -> [[Int]] | |
combinaisons [] = [] | |
combinaisons [x] = [[x]] | |
combinaisons [x, y] = [[x, y], [y, x]] | |
-- use fold | |
combinaisons arr = concat $ map (\y -> subcombinaisons y arr) arr | |
where | |
without e = filter (/= e) | |
subcombinaisons e list = map (e :) $ combinaisons $ without e list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment