Shuffle input (untested :-))
authorJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 20:42:14 +0000 (22:42 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 20:52:15 +0000 (22:52 +0200)
L-seed.cabal
src/dbclient.hs

index 9c4c5c5..87a044b 100644 (file)
@@ -75,7 +75,8 @@ Library
   if flag(Database) 
     Build-Depends:
         HDBC-odbc,
-        HDBC
+        HDBC,
+        random-shuffle == 0.0.2
     Exposed-Modules:
         Lseed.DB
 
index 3bac4d2..18ee852 100644 (file)
@@ -10,8 +10,15 @@ import Text.Printf
 import System.Environment
 import Data.Monoid
 import Data.Maybe
+import System.Random
+import System.Random.Shuffle (shuffle')
 
-getDBGarden conf = spread <$> mapMaybe compileDBCode <$> getCodeToRun conf
+randomize l = shuffle' l (length l) <$> newStdGen
+
+getDBGarden conf = do
+       dbc <- getCodeToRun conf
+       gs <- randomize $ mapMaybe compileDBCode dbc
+       return $ spread gs
   where spread gs = zipWith (\(u,n,g) p ->
                 Planted ((fromIntegral p + 0.5) / l)
                         u