diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-03-19 00:56:18 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-03-19 00:56:18 +0800 |
commit | 619ec3907aec1a058e745afaf6ff55b0c76a0ddd (patch) | |
tree | 28ace2cbc3e99513158f03ca88f069f49894a718 | |
parent | 681c2a9ea65a6c6cd5935763765f7ef91c024b7b (diff) | |
download | h99-619ec3907aec1a058e745afaf6ff55b0c76a0ddd.tar.gz h99-619ec3907aec1a058e745afaf6ff55b0c76a0ddd.tar.bz2 h99-619ec3907aec1a058e745afaf6ff55b0c76a0ddd.zip |
m27
-rw-r--r-- | h27.hs | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -5,7 +5,8 @@ combination _ [] = [] combination c (x:xs) = (map ((x:).fst &&& snd) (combination (c-1) xs)) ++ (map (fst &&& (x:).snd) (combination c xs)) group :: [Int] -> [a] -> [[[a]]] -group [n] xs = map ((:[]).fst) (combination n xs) +group [] _ = [[]] +-- group [n] xs = map ((:[]).fst) (combination n xs) group (n:ns) xs = concatMap (\(comb,rest) -> map (comb:) (group ns rest)) (combination n xs) group' [] = const [[]] |