random-extras-0.18.1: Additional functions for random values.

Portabilityportable
Stabilityexperimental

Data.Random.Dovetail

Contents

Description

Functions for splitting a deck of cards like game players.

Decks are represented by Seqs, because these efficiently support the required operations.

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

Synopsis

Splitting decks

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

Split a deck into two roughly equal halves.

generalizedSplitDeck :: Int -> Seq a -> RVar [Seq a]Source

Split a deck into n roughly equal parts.

Riffling decks together

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

Riffle two halves of a deck into one deck.

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

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

Dovetail shuffle a deck repeatedly for n times.

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.