diff options
-rw-r--r-- | h26.hs | 5 | ||||
-rw-r--r-- | h27.hs | 8 |
2 files changed, 13 insertions, 0 deletions
@@ -0,0 +1,5 @@ +combination :: Int -> [a] -> [[a]] +combination 0 _ = [[]] +combination _ [] = [] +combination c (x:xs) = (map (x:) (combination (c-1) xs)) ++ (combination c xs) + @@ -0,0 +1,8 @@ +combination :: Int -> [a] -> [[a]] +combination 0 _ = [[]] +combination _ [] = [] +combination c (x:xs) = (map (x:) (combination (c-1) xs)) ++ (combination c xs) + +group :: [Int] -> [a] -> [a] +group [] xs = [[xs]] +group (n:ns) xs = map ((combination n) . head) group (n:ns) xs |