added practicum files, updated gitignore
[fp1415.git] / files / practicum / Map.icl
1 implementation module Map
2
3 import BinTree // voor het type Tree en voorbeelden t0 t/m t7
4 import Maybe // voor het type Maybe
5 import StdList // voor de standaard map functie
6
7 class Map c :: ... // maak deze type constructor class af
8
9 instance Map [] where ... // maak deze instance af
10 instance Map Maybe where ... // maak deze instance af
11 instance Map Tree where ... // maak deze instance af
12
13 // voorgegeven functie, specifiek voor Maybe:
14 mapMaybe :: (a -> b) (Maybe a) -> Maybe b
15 mapMaybe f Nothing = Nothing
16 mapMaybe f (Just x) = Just (f x)
17
18 // voorgegeven functie, specifiek voor Tree:
19 mapTree :: (a -> b) (Tree a) -> Tree b
20 mapTree f Leaf = Leaf
21 mapTree f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r)