summaryrefslogtreecommitdiff
path: root/fp2/week1/camil
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/week1/camil
parentweek3 jow (diff)
initial start with week3, wine yay
Diffstat (limited to 'fp2/week1/camil')
-rw-r--r--fp2/week1/camil/RandomGetallen.dcl7
-rw-r--r--fp2/week1/camil/RandomGetallen.icl29
2 files changed, 0 insertions, 36 deletions
diff --git a/fp2/week1/camil/RandomGetallen.dcl b/fp2/week1/camil/RandomGetallen.dcl
deleted file mode 100644
index 2ca4b27..0000000
--- a/fp2/week1/camil/RandomGetallen.dcl
+++ /dev/null
@@ -1,7 +0,0 @@
-definition module RandomGetallen
-
-import Random
-
-random_n :: Int RandomSeed -> ([Int],RandomSeed)
-random_inf :: RandomSeed -> [Int]
-shuffle :: [a] RandomSeed -> [a]
diff --git a/fp2/week1/camil/RandomGetallen.icl b/fp2/week1/camil/RandomGetallen.icl
deleted file mode 100644
index a0a21bf..0000000
--- a/fp2/week1/camil/RandomGetallen.icl
+++ /dev/null
@@ -1,29 +0,0 @@
-implementation module RandomGetallen
-
-import StdEnv, Random
-
-random_n :: Int RandomSeed -> ([Int],RandomSeed)
-random_n 0 seed = ([], seed)
-random_n n seed = ([r:rs], s`)
-where
- (rs,s`) = random_n (n-1) s
- (r,s) = random seed
-
-random_inf :: RandomSeed -> [Int]
-random_inf s = iterateSt random s
-
-iterateSt :: (s -> (a,s)) s -> [a]
-iterateSt f s = [a : iterateSt f s`]
-where
- (a,s`) = f s
-
-shuffle :: [a] RandomSeed -> [a]
-shuffle xs s = (perms xs)!!(fst (random s) rem (factorial (length xs)))
-
-perms :: [a] -> [[a]]
-perms [] = [[]]
-perms xs = [[xs!!i : xs`] \\ i <- [0..length xs - 1] , xs` <- perms (take i xs ++ drop (i+1) xs)]
-
-factorial :: Int -> Int
-factorial 0 = 1
-factorial n = n * factorial (n-1)