--- /dev/null
+definition module StdSortList\r
+\r
+import StdClass\r
+\r
+:: SortList a\r
+\r
+newSortList :: SortList a // lege gesorteerde lijst\r
+memberSort :: a (SortList a) -> Bool | Eq, Ord a // is element van\r
+insertSort :: a (SortList a) -> SortList a | Ord a // voeg element toe\r
+removeFirst :: a (SortList a) -> SortList a | Eq, Ord a // verwijder eerste voorkomen\r
+removeAll :: a (SortList a) -> SortList a | Eq, Ord a // verwijder alle voorkomens\r
+elements :: (SortList a) -> [a] // geef alle elementen\r
+count :: (SortList a) -> Int // aantal elementen\r
+\r
+minimum :: (SortList a) -> a // huidige minimum waarde\r
+maximum :: (SortList a) -> a // huidige maximum waarde\r
+\r
+mergeSortList :: (SortList a) (SortList a) -> SortList a | Eq, Ord a // meng gesorteerde lijsten\r
--- /dev/null
+implementation module StdSortList\r
+\r
+import StdEnv\r
+\r
+:: SortList a = SortList (SortList a, a, SortList a) | Empty\r
+\r
+newSortList :: SortList a\r
+newSortList = Empty\r
+\r
+memberSort :: a (SortList a) -> Bool | Eq, Ord a\r
+memberSort x Empty = False\r
+memberSort x (le, el, gr)\r
+| x == e = True\r
+| x < el = memberSort x le\r
+| otherwise = memberSort x gr\r
+\r
+insertSort :: a (SortList a) -> SortList a | Ord a\r
+memberSort x Empty = Sortlist (Empty, x, Empty)\r
+memberSort x (le, el, gr)\r
+\r
+removeFirst :: a (SortList a) -> SortList a | Eq, Ord a\r
+removeFirst e ([], _)_ = ([], _)\r
+\r
+removeAll :: a (SortList a) -> SortList a\r
+removeAll _ _ = Empty\r
+\r
+elements :: (SortList a) -> [a]\r
+elements _ = []\r
+\r
+count :: (SortList a) -> Int\r
+count _ = 0\r
+\r
+minimum :: (SortList a) -> a\r
+minimum _ = 0\r
+\r
+maximum :: (SortList a) -> a\r
+maximum _ = 0\r
+\r
+mergeSortList :: (SortList a) (SortList b) -> (SortList a)\r
+mergeSortList _ _ = Empty\r
+\r
+Start :: String\r
+Start = newSortList\r
--- /dev/null
+definition module StdStack\r
+\r
+:: Stack a\r
+\r
+newStack :: Stack a // lege stack\r
+push :: a (Stack a) -> Stack a // plaats nieuw element bovenop de stack\r
+pushes :: [a] (Stack a) -> Stack a // plaats elementen achtereenvolgens bovenop stack\r
+pop :: (Stack a) -> Stack a // haal top element van stack\r
+popn :: Int (Stack a) -> Stack a // haal bovenste $n$ top elementen van stack\r
+top :: (Stack a) -> a // geef top element van stack\r
+topn :: Int (Stack a) -> [a] // geef bovenste $n$ top elementen van stack\r
+elements :: (Stack a) -> [a] // geef alle elementen van stack\r
+count :: (Stack a) -> Int // tel aantal elementen in stack\r
--- /dev/null
+implementation module StdStack\r
+\r
+import StdEnv\r
+\r
+:: Stack a = Stack [a]\r
+\r
+newStack :: Stack a\r
+newStack = Stack []\r
+\r
+push :: a (Stack a) -> Stack a\r
+push x (Stack xs) = Stack [x:xs]\r
+\r
+pushes :: [a] (Stack a) -> Stack a\r
+pushes [] (Stack s) = Stack s\r
+pushes [x:xs] (Stack s) = pushes xs (push x (Stack s))\r
+\r
+pop :: (Stack a) -> Stack a\r
+pop (Stack []) = abort "Can't pop from empty stack..."\r
+pop (Stack [x:xs]) = Stack xs\r
+\r
+popn :: Int (Stack a) -> Stack a\r
+popn 0 s = s\r
+popn n s = popn (n-1) (pop s)\r
+\r
+top :: (Stack a) -> a\r
+top (Stack []) = abort "Can't give top of empty stack..."\r
+top (Stack [x:_]) = x\r
+\r
+topn :: Int (Stack a) -> [a]\r
+topn 0 _ = []\r
+topn n x = [top x:topn (n-1) (pop x)]\r
+\r
+elements :: (Stack a) -> [a]\r
+elements (Stack s) = s\r
+\r
+count :: (Stack a) -> Int\r
+count (Stack []) = 0\r
+count (Stack [_:xs]) = 1 + count (Stack xs)\r
+\r
+Start = ( "s0 = newStack = ", s0,'\n'\r
+ , "s1 = push 1 s0 = ", s1,'\n'\r
+ , "s2 = pushes [2..5] s1 = ",s2,'\n'\r
+ , "s3 = pop s2 = ", s3,'\n'\r
+ , "s4 = popn 3 s3 = ", s4,'\n'\r
+ , "s5 = top s4 = ", s5,'\n'\r
+ , "s6 = topn 3 s2 = ", s6,'\n'\r
+ , "s7 = elements s2 = ", s7,'\n'\r
+ )\r
+where\r
+ s0 = newStack\r
+ s1 = push 1 s0\r
+ s2 = pushes [2..5] s1\r
+ s3 = pop s2\r
+ s4 = popn 3 s3\r
+ s5 = top s4\r
+ s6 = topn 3 s2\r
+ s7 = elements s2\r