From 619ec3907aec1a058e745afaf6ff55b0c76a0ddd Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Thu, 19 Mar 2015 00:56:18 +0800 Subject: m27 --- h27.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/h27.hs b/h27.hs index 6666203..8c0dab1 100644 --- a/h27.hs +++ b/h27.hs @@ -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 [[]] -- cgit v1.2.3-70-g09d2