forked from Umbc331Assignment3/assignment3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmattsjunk.hs
59 lines (52 loc) · 1.83 KB
/
mattsjunk.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{-
Takes list of total students [1..howevermany]
Outputs a list of tuples first element being the student ID number
Second being a list
for storing the students already been grouped with
-}
studentstruct ss = [(x,[x]) | x <- ss]
{-
s = the student to add
curstu = the tuple where first element is the student id
and the second element is the list of already grouped students
-}
addstudent s curstu = head [ (y, s: x) | let x = snd curstu , let y = fst curstu]
--TODO get type signature right
--updategroupedlist :: (Int x Int [y]) => x -> [y] -> [z]
--updategroupedlist n l = filter (not . (==n)) [l]
{-
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
-}
checkindivdual lookingfor currentstudent =
case elem lookingfor $ snd currentstudent of
True -> Right True
False -> Left $ addstudent lookingfor currentstudent
{-
altcheckind lookingfor currentstudent =
(if elem lookingfor $ snd currentstudent
then do {
return
}
else
do {
addstudent lookingfor currentstudent
}
-}
--Checks if the total number of students can be split into said group size
checkmod x y = (if mod x y == 0
then putStrLn "Yay"
else putStrLn $"Cannot pair up " ++
(show x) ++ " students into groups of "
++ show(y) ++ " across eight assignments")
{-
should iterate entire list of students
call checkindividual lfor = student to look for
x is just the size of list (should be a way to hack it to use "length students")
Error about show IO cause it prints yay if finds it instead of taking real action
too lazy right now to figure it out
-}
checkall students lfor x= [checkindivdual lfor (students !! index )| index <- [1..x]]