mijn uitwerking
authorcharlie <charlie.gerhardus@student.ru.nl>
Sun, 6 Dec 2015 15:54:27 +0000 (16:54 +0100)
committercharlie <charlie.gerhardus@student.ru.nl>
Sun, 6 Dec 2015 15:54:27 +0000 (16:54 +0100)
a11/charlie/skeleton11.icl [new file with mode: 0644]
a11/charlie/skeleton11.prj [new file with mode: 0644]

diff --git a/a11/charlie/skeleton11.icl b/a11/charlie/skeleton11.icl
new file mode 100644 (file)
index 0000000..d946aa4
--- /dev/null
@@ -0,0 +1,55 @@
+module skeleton11\r
+\r
+import StdEnv\r
+\r
+:: Prog :== [Instr]\r
+\r
+:: Instr = Write Expr\r
+       | Atomic Prog\r
+\r
+:: Expr = Int   Int\r
+        | Plus  Expr Expr\r
+        | Times Expr Expr\r
+        | Read\r
+\r
+eval :: Int Expr -> Int\r
+eval _ (Int x) = x\r
+eval val (Plus l r) = eval val l + eval val r\r
+eval val (Times l r) = eval val l * eval val r\r
+eval val Read = val\r
+\r
+exec :: Int Instr -> Int\r
+exec val (Write exp) = eval val exp\r
+exec val (Atomic p) = hd (stepAll val [p] [])\r
+\r
+step :: Int Prog -> (Int, Prog)\r
+step val [i:is] = (exec val i, is)\r
+\r
+stepAll :: Int [Prog] [Prog] -> [Int]\r
+stepAll val [] [] = [val]\r
+stepAll val [] pps = stepAll val pps []\r
+stepAll val [[]:ps] pps = stepAll val ps pps\r
+stepAll val [p:[]] pps = stepAll val` [] (pps++[p`]) where\r
+       (val`, p`) = step val p\r
+stepAll val [p:ps] pps = stepAll val` [p`:ps] pps ++ stepAll val ps (pps++[p]) where\r
+       (val`, p`) = step val p\r
+\r
+possibleResults :: [Prog] -> [Int]\r
+possibleResults ps = filterResults (stepAll 0 ps [])\r
+\r
+filterResults :: [Int] -> [Int]\r
+filterResults [] = []\r
+filterResults [r:rs] | isMember r rs = filterResults rs\r
+                     | otherwise = [r:filterResults rs]\r
+\r
+prog0 = [ Write (Int 12)\r
+        , Write (Plus Read (Int 1))\r
+        ]\r
+prog1 = [ Write (Times Read (Int 2)) ]\r
+prog2 = [ Atomic prog0 ]\r
+test0 = [ prog0 ]       // result should be [13]\r
+test1 = [ prog0, prog1] // result should be [13, 25, 26] (or any permutation, the order doesn't matter)\r
+test2 = [ prog2, prog1 ]\r
+\r
+Start = possibleResults test2\r
+\r
diff --git a/a11/charlie/skeleton11.prj b/a11/charlie/skeleton11.prj
new file mode 100644 (file)
index 0000000..d102507
--- /dev/null
@@ -0,0 +1,322 @@
+Version: 1.4\r
+Global\r
+       ProjectRoot:    .\r
+       Target: StdEnv\r
+       Exec:   {Project}\skeleton11.exe\r
+       CodeGen\r
+               CheckStacks:    False\r
+               CheckIndexes:   True\r
+       Application\r
+               HeapSize:       2097152\r
+               StackSize:      512000\r
+               ExtraMemory:    81920\r
+               IntialHeapSize: 204800\r
+               HeapSizeMultiplier:     4096\r
+               ShowExecutionTime:      False\r
+               ShowGC: False\r
+               ShowStackSize:  False\r
+               MarkingCollector:       False\r
+               StandardRuntimeEnv:     True\r
+               Profile\r
+                       Memory: False\r
+                       MemoryMinimumHeapSize:  0\r
+                       Time:   False\r
+                       Stack:  False\r
+               Output\r
+                       Output: ShowConstructors\r
+                       Font:   Courier\r
+                       FontSize:       9\r
+                       WriteStdErr:    False\r
+       Link\r
+               LinkMethod:     Static\r
+               GenerateRelocations:    False\r
+               GenerateLinkMap:        False\r
+               LinkResources:  False\r
+               ResourceSource: \r
+               GenerateDLL:    False\r
+               ExportedNames:  \r
+       Paths\r
+               Path:   {Project}\r
+       Precompile:     \r
+       Postlink:       \r
+MainModule\r
+       Name:   skeleton11\r
+       Dir:    {Project}\r
+       Compiler\r
+               NeverMemoryProfile:     False\r
+               NeverTimeProfile:       False\r
+               StrictnessAnalysis:     True\r
+               ListTypes:      StrictExportTypes\r
+               ListAttributes: True\r
+               Warnings:       True\r
+               Verbose:        True\r
+               ReadableABC:    False\r
+               ReuseUniqueNodes:       True\r
+               Fusion: False\r
+OtherModules\r
+       Module\r
+               Name:   StdArray\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdBool\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdChar\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdCharList\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdClass\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdEnum\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdEnv\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdFile\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdFunc\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdInt\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdList\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdMisc\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdOrdList\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdOverloaded\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdReal\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdString\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   StdTuple\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   _SystemArray\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r
+       Module\r
+               Name:   _SystemEnum\r
+               Dir:    {Application}\Libraries\StdEnv\r
+               Compiler\r
+                       NeverMemoryProfile:     False\r
+                       NeverTimeProfile:       False\r
+                       StrictnessAnalysis:     True\r
+                       ListTypes:      StrictExportTypes\r
+                       ListAttributes: True\r
+                       Warnings:       True\r
+                       Verbose:        True\r
+                       ReadableABC:    False\r
+                       ReuseUniqueNodes:       True\r
+                       Fusion: False\r