summaryrefslogtreecommitdiff
path: root/fp2/week3/mart/GetallenRaden.icl
diff options
context:
space:
mode:
authorMart Lubbers2015-04-28 21:18:32 +0200
committerMart Lubbers2015-04-28 21:18:32 +0200
commiteb801d874c5101539c27703ec3854ad98a099d3f (patch)
tree3b7bbb704c52ab1cb010c55ff0b4d22b97175e52 /fp2/week3/mart/GetallenRaden.icl
parentweek3 jow (diff)
initial start with week3, wine yay
Diffstat (limited to 'fp2/week3/mart/GetallenRaden.icl')
-rw-r--r--fp2/week3/mart/GetallenRaden.icl29
1 files changed, 27 insertions, 2 deletions
diff --git a/fp2/week3/mart/GetallenRaden.icl b/fp2/week3/mart/GetallenRaden.icl
index f03750a..37584fb 100644
--- a/fp2/week3/mart/GetallenRaden.icl
+++ b/fp2/week3/mart/GetallenRaden.icl
@@ -8,6 +8,31 @@ import StdEnv
import StdDynamic, StdDynamicFileIO // nodig voor dynamics en dynamics in files
import StdFileSelect // platform file-selector dialoog
-Start :: *World -> *World
+// Generation program
+//fib :: [Int]
+//fib = [fib` i \\ i <- [0..]]
+// where
+// fib` 0 = 0
+// fib` 1 = 1
+// fib` n = fib` (n-1) + fib` (n-2)
+//
+//Start :: *World -> (Bool, *World)
+//Start world = writeDynamic "fib" (dynamic fib) world
+
+makeSeq :: Dynamic -> [Int]
+makeSeq (x :: [Int]) = x
+makeSeq _ = abort "You selected a file not containing a sequence"
+
+loadSeq :: String *World -> *([Int], *World)
+loadSeq s world
+# s = let l = size s in s % (0, l-5)
+# (ok, dyn, world) = readDynamic s world
+| not ok = abort "You didn't select a dynamic file"
+| otherwise = (makeSeq dyn, world)
+
+Start :: *World -> ([Int], *World)
Start world
- = world
+# (inputfilepath, world) = selectInputFile world
+| isNothing inputfilepath = abort "Please select a file"
+# (sequence, world) = loadSeq (fromJust inputfilepath) world
+| otherwise = (take 20 sequence, world)