summaryrefslogtreecommitdiff
path: root/files/practicum/Map.icl
blob: deccc077e6a0052ba5f27f45fc5544d998df612d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
implementation module Map

import BinTree		// voor het type Tree en voorbeelden t0 t/m t7
import Maybe        // voor het type Maybe
import StdList      // voor de standaard map functie

class Map c :: ...            // maak deze type constructor class af

instance Map []    where ...  // maak deze instance af
instance Map Maybe where ...  // maak deze instance af
instance Map Tree  where ...  // maak deze instance af

// voorgegeven functie, specifiek voor Maybe:
mapMaybe 		        :: (a -> b) (Maybe a) -> Maybe b
mapMaybe f Nothing	    = Nothing
mapMaybe f (Just x)	    = Just (f x)

// voorgegeven functie, specifiek voor Tree:
mapTree 			    :: (a -> b) (Tree a) -> Tree b
mapTree f Leaf		    = Leaf
mapTree f (Node x l r)	= Node (f x) (mapTree f l) (mapTree f r)