Skip to content

Instantly share code, notes, and snippets.

@ThomasCrevoisier
Created June 30, 2016 21:18
Show Gist options
  • Save ThomasCrevoisier/da7b0915188e4cdf0023a035fda22be7 to your computer and use it in GitHub Desktop.
Save ThomasCrevoisier/da7b0915188e4cdf0023a035fda22be7 to your computer and use it in GitHub Desktop.
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