diff options
author | Joe Zhao <ztuowen@gmail.com> | 2016-01-28 13:27:16 -0700 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2016-01-28 13:27:16 -0700 |
commit | 9d9cfd3c2f7ab36982cb569027cf831e95ee42ea (patch) | |
tree | 2a63b4d23ae6073d051c5a9802ab000439f89f78 /Shuffle.hs | |
parent | 7c8e53da6280751598e1c62fdaca314d5a4b0aed (diff) | |
download | haskbox-9d9cfd3c2f7ab36982cb569027cf831e95ee42ea.tar.gz haskbox-9d9cfd3c2f7ab36982cb569027cf831e95ee42ea.tar.bz2 haskbox-9d9cfd3c2f7ab36982cb569027cf831e95ee42ea.zip |
sort
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) + |