RosettaCodeData/Task/Combinations/Haskell/combinations-7.hs
2014-04-02 16:56:35 +00:00

5 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