diff options
Diffstat (limited to 'Shuffle.hs')
-rw-r--r-- | Shuffle.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Shuffle.hs b/Shuffle.hs new file mode 100644 index 0000000..d1ad24a --- /dev/null +++ b/Shuffle.hs @@ -0,0 +1,11 @@ +module Shuffle (shuffle) where + +import System.Random + +shuffle [] = return [] +shuffle xs = do + i <- getStdRandom(randomR (0,(length xs)-1))::IO(Int) + let (h:rst) = drop i xs + oth <- shuffle $ (take i xs) ++ rst + return (h:oth) + |