99-haskell-problems/Problems 21-28/problem_26.hs

10 lines
261 B
Haskell

combinations :: Int -> [a] -> [[a]]
combinations 0 _ = []
combinations _ [] = []
combinations n (hd : tl) = with ++ without
where
with =
if n == 1
then [[hd]]
else [(hd :)] <*> combinations (n - 1) tl
without = combinations n tl