Portability | portable |
---|---|

Stability | experimental |

Functions for splitting a deck of cards like game players.

Decks are represented by `Seq`

s, because these efficiently support the required operations.

- See:
- Bayer, Diaconis
*Trailing the Dovetail Shuffle to its Lair*http://projecteuclid.org/euclid.aoap/1177005705

- splitDeck :: Seq a -> RVar (Seq a, Seq a)
- generalizedSplitDeck :: Int -> Seq a -> RVar [Seq a]
- riffleDecks :: Seq a -> Seq a -> RVar (Seq a)
- generalizedRiffleDecks :: [Seq a] -> RVar (Seq a)
- inverseRiffleDecks :: Seq a -> RVar (Seq a, Seq a)
- generalizedInverseRiffleDecks :: Int -> Seq a -> RVar (Seq (Seq a))
- dovetail :: Seq a -> RVar (Seq a)
- generalizedDovetail :: Int -> Seq a -> RVar (Seq a)
- dovetails :: Int -> Seq a -> RVar (Seq a)
- generalizedDovetails :: Int -> Int -> Seq a -> RVar (Seq a)
- inverseDovetail :: Seq a -> RVar (Seq a)
- generalizedInverseDovetail :: Int -> Seq a -> RVar (Seq a)
- faceUpFaceDown :: Seq a -> RVar (Seq a)

# Splitting decks

# Riffling decks together

generalizedRiffleDecks :: [Seq a] -> RVar (Seq a)Source

Riffle *n* parts into one deck.

## Inverse riffling

inverseRiffleDecks :: Seq a -> RVar (Seq a, Seq a)Source

Perform an inverse riffle, i.e. letting the cards from a deck drop randomly into two heaps.

generalizedInverseRiffleDecks :: Int -> Seq a -> RVar (Seq (Seq a))Source

Perform an inverse riffle, i.e. letting the cards from a deck drop
randomly into *n* heaps.

# Dovetail shuffling

dovetail :: Seq a -> RVar (Seq a)Source

Dovetail shuffle a deck, i.e. split the deck with splitDeck and riffle
the resulting halves with `riffleDecks`

.

generalizedDovetail :: Int -> Seq a -> RVar (Seq a)Source

Dovetail shuffle a deck (generalized), i.e. split the deck into *n* parts
and riffle them back together.

## Repeated dovetail shuffling

generalizedDovetails :: Int -> Int -> Seq a -> RVar (Seq a)Source

Dovetail shuffle a deck repeatedly for *shuffles* times,
using *parts* parts.

*Invocation:* `generalizedDovetails shuffles parts deck`

## Inverse dovetail shuffling

inverseDovetail :: Seq a -> RVar (Seq a)Source

Perform an inverse dovetail shuffle, i.e. letting the cards from a deck drop randomly into two heaps and then stack these heaps.

generalizedInverseDovetail :: Int -> Seq a -> RVar (Seq a)Source

Perform a generalized inverse dovetail shuffle, i.e. letting the cards
from a deck drop randomly into *n* heaps and then stack them back together.

# Face up, face down shuffling

faceUpFaceDown :: Seq a -> RVar (Seq a)Source

Perform a *face up, face down* shuffle, which is like a dovetail shuffle
where the lower of the two halves is reversed.