Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwarz1 committed Oct 8, 2014
1 parent da96eac commit 18c0e15
Showing 1 changed file with 29 additions and 11 deletions.
40 changes: 29 additions & 11 deletions assignment3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,52 @@ import Control.Applicative




{-
Combinations gets all possible combinations of a list of numbers
-}
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)]


{-
firstpos gets the first list if the item is 1
-}
firstpos xs = [x | x <- xs, head x == 1 ]

{-
scondpos gets the first list with first item 2
-}
secondpos xs = [x | x <- xs, (head (tail x)) == 2 ]

{-
Print all the lists within combinations by taking them out of the list
-}
showall xs = [y | x <- xs, y <-x, y ]

{-
-}
each xs stu = [checkindividual y stu | y <- x,x <-xs]


{-
creates a list of tuples containing an int and a
list of other ints meant to contain the student and
the students it has been grouped with
-}
studentstruct ss = [(x,[x]) | x <- ss]

{-
-}
fixstruct index student ss = do
let (fh,_:sh) = splitAt (index - 1) ss
fh ++ student : sh

{-
-}
checkindividual lookingfor currentstudent
|(elem lookingfor $ snd currentstudent )== True = True
|otherwise = False
Expand All @@ -35,20 +62,11 @@ checkindividual lookingfor currentstudent

groupedTogether xs ys = [ y : ys | y <- xs, (not (elem y ys))]

--checkeach xs cur
-- | (length xs) == numbuniquegroups = xs
-- | [ | (a,b,_,_) <- xs, a != b]
--buildassignmnet xs = [x:[] | x <- xs ]

--eliminate xs
-- | (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 []

--http://www.reddit.com/r/haskell/comments/1vras3/haskell_io_how_to_read_numbers/

Expand Down

0 comments on commit 18c0e15

Please sign in to comment.