Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sdwoodbury committed Oct 8, 2014
2 parents 9eafc03 + c092927 commit 8013e56
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions assignment3.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Control.Applicative

{-
Combinations gets all possible combinations of a list of numbers
http://www.haskell.org/haskellwiki/99_questions/Solutions/26
"99 Questions/Solutions/26." - HaskellWiki. N.p., n.d. Web. 07 Oct. 2014.
-}
combinations :: Int -> [a] -> [[a]]
combinations 0 _ = [[]]
Expand All @@ -28,12 +30,6 @@ 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]


{-
creates a list of tuples containing an int and a
list of other ints meant to contain the student and
Expand All @@ -42,14 +38,19 @@ each xs stu = [checkindividual y stu | y <- x,x <-xs]
studentstruct ss = [(x,[x]) | x <- ss]

{-
Remakes the studentstruct so that it is recreated
essentially the fix for not being able to pass by reference
-}
fixstruct index student ss = do
let (fh,_:sh) = splitAt (index - 1) ss
fh ++ student : sh

{-
studentstruct !! number gives you currentstudent
looking for is the student to check for
returns true if student has already been grouped with this student
otherwise will add student to group
TODO needs to the update grouped already list
-}
checkindividual lookingfor currentstudent
|(elem lookingfor $ snd currentstudent )== True = True
Expand All @@ -58,7 +59,6 @@ checkindividual lookingfor currentstudent


{-
TODO make output True for true conidtion
Checks if the total number of students can be split into said group size
-}
checkmod :: Int -> Int -> Bool
Expand All @@ -67,16 +67,11 @@ checkmod x y
| otherwise = False

{-
capture retrieves a list within another list if the element is in the first list
-}
groupedTogether xs ys = [ y : ys | y <- xs, (not (elem y ys))]


capture xs ys = length [x | x <- xs,(not (elem x ys))]


x = combinations 4 [1..10]

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


Expand Down

0 comments on commit 8013e56

Please sign in to comment.