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

6 lines
170 B
Haskell
Raw Permalink Normal View History

2014-04-02 16:56:35 +00:00
comb :: Int -> [a] -> [[a]]
comb m xs = combsBySize xs !! m
where
combsBySize = foldr f ([[]] : repeat [])
f x next = zipWith (++) (map (map (x:)) ([]:next)) next