-- Shuffle given pack of cards, using random seed.
shuffle :: Int -> [a] -> [a]
shuffle seed pack =
    let stdGen = mkStdGen seed
        -- A list of random indices.
        rndIdx 0   _   = []
        rndIdx len gen = [a] ++ (rndIdx (len - 1) gen')
            where
                (a, gen') = randomR (0, len - 1) gen
        -- Extract of random cards from the pack pk.
        result [] _   = []
        result pk idx = [card] ++ result pk' (tail idx)
            where
                i    = head idx                     -- current index
                card = pk !! i                      -- chosen random card
                pk'  = take i pk ++ drop (i+1) pk   -- pack without chosen card
        rndIdx' = rndIdx (length pack) stdGen
    in  result pack rndIdx'
shuffle :: Int -> [a] -> [a]
shuffle seed pack =
    let stdGen = mkStdGen seed
        -- A list of random indices.
        rndIdx 0   _   = []
        rndIdx len gen = [a] ++ (rndIdx (len - 1) gen')
            where
                (a, gen') = randomR (0, len - 1) gen
        -- Extract of random cards from the pack pk.
        result [] _   = []
        result pk idx = [card] ++ result pk' (tail idx)
            where
                i    = head idx                     -- current index
                card = pk !! i                      -- chosen random card
                pk'  = take i pk ++ drop (i+1) pk   -- pack without chosen card
        rndIdx' = rndIdx (length pack) stdGen
    in  result pack rndIdx'
shuffle seed pack =
    let stdGen = mkStdGen seed
        -- A list of random indices.
        rndIdx 0   _   = []
        rndIdx len gen = [a] ++ (rndIdx (len - 1) gen')
            where
                (a, gen') = randomR (0, len - 1) gen
        -- Extract of random cards from the pack pk.
        result [] _   = []
        result pk idx = [card] ++ result pk' (tail idx)
            where
                i    = head idx                     -- current index
                card = pk !! i                      -- chosen random card
                pk'  = take i pk ++ drop (i+1) pk   -- pack without chosen card
        rndIdx' = rndIdx (length pack) stdGen
    in  result pack rndIdx'