--- /dev/null
+definition module RandomGetallen\r
+\r
+import Random\r
+\r
+random_n :: Int RandomSeed -> ([Int],RandomSeed)\r
+random_inf :: RandomSeed -> [Int]\r
+shuffle :: [a] RandomSeed -> [a]\r
--- /dev/null
+implementation module RandomGetallen\r
+\r
+import StdEnv, Random\r
+\r
+random_n :: Int RandomSeed -> ([Int],RandomSeed)\r
+random_n 0 seed = ([], seed)\r
+random_n n seed = ([r:rs], s`)\r
+where \r
+ (rs,s`) = random_n (n-1) s\r
+ (r,s) = random seed \r
+\r
+random_inf :: RandomSeed -> [Int]\r
+random_inf s = iterateSt random s\r
+\r
+iterateSt :: (s -> (a,s)) s -> [a]\r
+iterateSt f s = [a : iterateSt f s`]\r
+where\r
+ (a,s`) = f s\r
+\r
+shuffle :: [a] RandomSeed -> [a]\r
+shuffle xs s = (perms xs)!!(fst (random s) rem (factorial (length xs)))\r
+\r
+perms :: [a] -> [[a]]\r
+perms [] = [[]]\r
+perms xs = [[xs!!i : xs`] \\ i <- [0..length xs - 1] , xs` <- perms (take i xs ++ drop (i+1) xs)]\r
+\r
+factorial :: Int -> Int\r
+factorial 0 = 1\r
+factorial n = n * factorial (n-1)\r