module Solutions.P26 (combinations) where
combinations :: Int -> [a] -> [[a]]
combinations :: forall a. Int -> [a] -> [[a]]
combinations Int
0 [a]
_ = [[]]
combinations Int
_ [] = []
combinations Int
1 [a
x] = [[a
x]]
combinations Int
n (a
x:[a]
xs) = Int -> [a] -> [[a]]
forall a. Int -> [a] -> [[a]]
combinations Int
n [a]
xs [[a]] -> [[a]] -> [[a]]
forall a. [a] -> [a] -> [a]
++ ([a] -> [a]) -> [[a]] -> [[a]]
forall a b. (a -> b) -> [a] -> [b]
map (a
x:) (Int -> [a] -> [[a]]
forall a. Int -> [a] -> [[a]]
combinations (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [a]
xs)