summaryrefslogtreecommitdiff
path: root/1415/files/practicum/Map.icl
diff options
context:
space:
mode:
authorCamil Staps2016-02-02 19:24:50 +0100
committerCamil Staps2016-02-02 19:24:50 +0100
commita7d7542dc646a5fd124ef71e71ce260889f1701b (patch)
tree04ed89503bbb3cc9933273a1326a53ca724c3492 /1415/files/practicum/Map.icl
parentweek6 camil: working positioning of lines by putting empties at left and righ... (diff)
Moved to 1415 directoryHEADmaster
Diffstat (limited to '1415/files/practicum/Map.icl')
-rw-r--r--1415/files/practicum/Map.icl21
1 files changed, 21 insertions, 0 deletions
diff --git a/1415/files/practicum/Map.icl b/1415/files/practicum/Map.icl
new file mode 100644
index 0000000..deccc07
--- /dev/null
+++ b/1415/files/practicum/Map.icl
@@ -0,0 +1,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)