summaryrefslogtreecommitdiff
path: root/fp2/week3/mart/StdDynSet.icl
blob: ffc2590f9b0bfd13bd13eeea61e00c7811156750 (plain) (blame)
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
implementation module StdDynSet

import StdEnv
import StdDynamic

class Set a | TC, ==, toString a

:: Set = Set [Dynamic]

instance zero     Set
where zero = Set []

instance toString Set
where toString (Set a) = abort "toString not implemented"
	
instance == Set
where == a b = abort "== instance voor Set nog niet geimplementeerd.\n"

toSet :: a -> Set | Set a
toSet a = Set [dynamic a]

nrOfElts :: Set -> Int
nrOfElts (Set a) = length a

isEmptySet :: Set -> Bool
isEmptySet (Set []) = True
isEmptySet _ = False

memberOfSet :: a Set -> Bool | Set a
memberOfSet _ (Set []) = False
memberOfSet x (Set [y:xs])
| isEqual x y = True
| otherwise = memberOfSet x xs

isSubset :: Set Set -> Bool
isSubset a b = abort "isSubset nog niet geimplementeerd.\n"

isStrictSubset :: Set Set -> Bool
isStrictSubset a b = abort "isStrictSubset nog niet geimplementeerd.\n"

union :: Set Set -> Set
union a b = abort "union nog niet geimplementeerd.\n"

intersection :: Set Set -> Set
intersection a b = abort "intersection nog niet geimplementeerd.\n"

without :: Set Set -> Set
without a b = abort "without nog niet geimplementeerd.\n"

Start :: Set
Start = toSet 1