From ff063321b82f9e982745948200ea165d06c1c8bf Mon Sep 17 00:00:00 2001 From: sdwoodbury Date: Tue, 7 Oct 2014 22:38:24 -0400 Subject: [PATCH] reOccurances for detecting repeat teammates --- alternative.hs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/alternative.hs b/alternative.hs index 6a0783c..7039a03 100644 --- a/alternative.hs +++ b/alternative.hs @@ -7,12 +7,22 @@ combinations :: Int -> [a] -> [[a]] combinations 0 _ = [[]] combinations n xs = [ xs !! i : x | i <- [0..(length xs)-1] , x <- combinations (n-1) (drop (i+1) xs)] + +{-captures all groups with no two groups having students grouped more than once-} +reOccurances:: (Ord a) => [a] -> [a] -> Int +reOccurances xs ys + | length xs == 0 = 0 + | length ys == 0 = 0 + | otherwise = length [x|x <- xs, elem x ys] + +getUnique :: + firstpos xs = [x | x <- xs, head x == 1 ] secondpos xs = [x | x <- xs, (head (tail x)) == 2 ] showall xs = [y | x <- xs, y <-x, y ] -each xs stu = [checkindividual y stu | y <- x,x <-xs] +--each xs stu = [checkindividual y stu | y <- x,x <-xs] studentstruct ss = [(x,[x]) | x <- ss] @@ -40,8 +50,4 @@ groupedTogether xs ys = [ y : ys | y <- xs, (not (elem y ys))] -- | (length xs) == numbuniquegroups/8 = xs -- | --capture :: Ord => [a] -> [b] -> Int -capture xs ys = length [x | x <- xs,(not (elem x ys))] - -x = combinations 4 [1..10] ---capture x []