try for week3 part 2
[fp1415.git] / fp2 / week3 / mart / StdDynSet.icl
1 implementation module StdDynSet
2
3 import StdEnv
4 import StdDynamic
5
6 class Set a | TC, ==, toString a
7
8 :: Set = Set [Dynamic]
9
10 instance zero Set
11 where zero = Set []
12
13 instance toString Set
14 where toString (Set a) = abort "toString not implemented"
15
16 instance == Set
17 where == a b = abort "== instance voor Set nog niet geimplementeerd.\n"
18
19 toSet :: a -> Set | Set a
20 toSet a = Set [dynamic a]
21
22 nrOfElts :: Set -> Int
23 nrOfElts (Set a) = length a
24
25 isEmptySet :: Set -> Bool
26 isEmptySet (Set []) = True
27 isEmptySet _ = False
28
29 memberOfSet :: a Set -> Bool | Set a
30 memberOfSet _ (Set []) = False
31 memberOfSet x (Set [y:xs])
32 | isEqual x y = True
33 | otherwise = memberOfSet x xs
34
35 isSubset :: Set Set -> Bool
36 isSubset a b = abort "isSubset nog niet geimplementeerd.\n"
37
38 isStrictSubset :: Set Set -> Bool
39 isStrictSubset a b = abort "isStrictSubset nog niet geimplementeerd.\n"
40
41 union :: Set Set -> Set
42 union a b = abort "union nog niet geimplementeerd.\n"
43
44 intersection :: Set Set -> Set
45 intersection a b = abort "intersection nog niet geimplementeerd.\n"
46
47 without :: Set Set -> Set
48 without a b = abort "without nog niet geimplementeerd.\n"
49
50 Start :: Set
51 Start = toSet 1