summaryrefslogtreecommitdiff
path: root/Shuffle.hs
blob: d1ad24a8baa830af3643748dc100d8e84433d5ff (plain)
1
2
3
4
5
6
7
8
9
10
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)