Skip to content

Commit

Permalink
needs fix and a print list statement
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwoodbury committed Oct 8, 2014
1 parent 1eace03 commit 867d111
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Alternative.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module Alternative where
import Data.List
import Control.Applicative


{-
Alternative.hs
Written by: Michael Schwarz Stuart Woodbury Neh Patel and Matthew Henry
see Assignment3.hs
-}


{-returns a double list of all size n combinations of list xs-}
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]

{-returns a list of all unique groupings
TODO fix type error-}
getUnique :: [[Int]] -> [[Int]]
getUnique xs
| length xs == 0 = [[]]
| otherwise = do
let x = head xs
let y = tail xs
return x : [z | z <- y, (reOccurances x z ) < 2] : [[]]

{-
Checks if the total number of students can be split into said group size
-}
checkmod :: Int -> Int -> Bool
checkmod x y
| mod x y == 0 = True
| otherwise = False

0 comments on commit 867d111

Please sign in to comment.