RosettaCodeData/Task/Combinations/Haskell/combinations-7.hs

6 lines
170 B
Haskell

comb :: Int -> [a] -> [[a]]
comb m xs = combsBySize xs !! m
where
combsBySize = foldr f ([[]] : repeat [])
f x next = zipWith (++) (map (map (x:)) ([]:next)) next