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