week3 jow
authorMart Lubbers <mart@martlubbers.net>
Tue, 28 Apr 2015 11:24:26 +0000 (13:24 +0200)
committerMart Lubbers <mart@martlubbers.net>
Tue, 28 Apr 2015 11:24:26 +0000 (13:24 +0200)
fp2/week3/mart/GetallenRaden.icl [new file with mode: 0644]
fp2/week3/mart/NotatieDynamics.icl [new file with mode: 0644]
fp2/week3/mart/StdDynSet.dcl [new file with mode: 0644]
fp2/week3/mart/StdDynSet.icl [new file with mode: 0644]

diff --git a/fp2/week3/mart/GetallenRaden.icl b/fp2/week3/mart/GetallenRaden.icl
new file mode 100644 (file)
index 0000000..f03750a
--- /dev/null
@@ -0,0 +1,13 @@
+module GetallenRaden\r
+\r
+/*     Dynamics werken alleen met de 32-bit versie van de Clean compiler.\r
+       (*) Gebruik Environment 'Experimental'\r
+       (*) In Project:Project Options: zet vlag 'Enable dynamics' aan\r
+*/\r
+import StdEnv\r
+import StdDynamic, StdDynamicFileIO            // nodig voor dynamics en dynamics in files\r
+import StdFileSelect                                   // platform file-selector dialoog\r
+\r
+Start :: *World -> *World\r
+Start world\r
+       = world\r
diff --git a/fp2/week3/mart/NotatieDynamics.icl b/fp2/week3/mart/NotatieDynamics.icl
new file mode 100644 (file)
index 0000000..da90675
--- /dev/null
@@ -0,0 +1,25 @@
+module NotatieDynamics\r
+\r
+import StdEnv\r
+import StdDynamic, StdDynamicFileIO\r
+\r
+Start = f4 f3\r
+\r
+f1 :: Int Int -> Int\r
+f1 (x :: Int) y = x + y\r
+\r
+f2 :: Bool a a -> a\r
+f2 (b :: Bool) (e1 :: a) (e2 :: a) = dynamic if b e1 e2 :: a\r
+\r
+f3 :: [Int]\r
+f3 = dynamic map fib [1 ..]\r
+\r
+fib 0 = 1\r
+fib 1 = 1\r
+fib n = fib (n-1) + fib (n-2)\r
+\r
+f4 :: [Int] -> [Int]\r
+f4 (xs :: [Int]) = take 10 xs\r
+\r
+f5 :: [Int] -> [Int]\r
+f5 = f4 f3\r
diff --git a/fp2/week3/mart/StdDynSet.dcl b/fp2/week3/mart/StdDynSet.dcl
new file mode 100644 (file)
index 0000000..de9a9b7
--- /dev/null
@@ -0,0 +1,24 @@
+definition module StdDynSet\r
+\r
+import StdOverloaded\r
+\r
+class Set a | TC, ==, toString a\r
+\r
+:: Set\r
+\r
+instance zero     Set\r
+instance toString Set\r
+instance ==       Set\r
+\r
+toSet                  :: a       -> Set  | Set a\r
+\r
+nrOfElts               ::     Set -> Int\r
+isEmptySet             ::     Set -> Bool\r
+\r
+memberOfSet            :: a   Set -> Bool | Set a\r
+isSubset               :: Set Set -> Bool\r
+isStrictSubset :: Set Set -> Bool\r
+\r
+union                  :: Set Set -> Set\r
+intersection   :: Set Set -> Set\r
+without                        :: Set Set -> Set\r
diff --git a/fp2/week3/mart/StdDynSet.icl b/fp2/week3/mart/StdDynSet.icl
new file mode 100644 (file)
index 0000000..ee43631
--- /dev/null
@@ -0,0 +1,44 @@
+implementation module StdDynSet\r
+\r
+import StdEnv\r
+import StdDynamic\r
+\r
+class Set a | TC, ==, toString a\r
+\r
+:: Set = Set [Dynamic]\r
+\r
+instance zero     Set\r
+where zero = abort "zero instance voor Set nog niet geimplementeerd.\n"\r
+\r
+instance toString Set\r
+where toString a = abort "toString instance voor Set nog niet geimplementeerd.\n"\r
+\r
+instance == Set\r
+where == a b = abort "== instance voor Set nog niet geimplementeerd.\n"\r
+\r
+toSet :: a -> Set | Set a\r
+toSet a = abort "toSet nog niet geimplementeerd.\n"\r
+\r
+nrOfElts :: Set -> Int\r
+nrOfElts a = abort "nrOfElts nog niet geimplementeerd.\n"\r
+\r
+isEmptySet :: Set -> Bool\r
+isEmptySet a = abort "isEmptySet nog niet geimplementeerd.\n"\r
+\r
+memberOfSet :: a Set -> Bool | Set a\r
+memberOfSet x a = abort "memberOfSet nog niet geimplementeerd.\n"\r
+\r
+isSubset :: Set Set -> Bool\r
+isSubset a b = abort "isSubset nog niet geimplementeerd.\n"\r
+\r
+isStrictSubset :: Set Set -> Bool\r
+isStrictSubset a b = abort "isStrictSubset nog niet geimplementeerd.\n"\r
+\r
+union :: Set Set -> Set\r
+union a b = abort "union nog niet geimplementeerd.\n"\r
+\r
+intersection :: Set Set -> Set\r
+intersection a b = abort "intersection nog niet geimplementeerd.\n"\r
+\r
+without :: Set Set -> Set\r
+without a b = abort "without nog niet geimplementeerd.\n"\r