Deck v1.1.0 Deck View Source

Get, shuffle and deal a deck of playing cards of any size (from 4 to 52 cards).

Link to this section Summary

Functions

"Burns" n_cards in the deck and returns the rest of the deck.

Returns n_cards from the deck and the rest of the deck.

Returns a full deck of cards (52 cards) ordered by rank.

Returns a deck containing high n_cards ordered by rank.

Returns a deck containing low n_cards ordered by rank.

Shuffles the deck using the modern version of the Fisher–Yates shuffle algorithm.

Returns a full shuffled deck of cards (52 cards).

Returns a shuffled deck containing high n_cards.

Returns a shuffled deck containing low n_cards.

Returns number of cards left in the deck.

Link to this section Functions

"Burns" n_cards in the deck and returns the rest of the deck.

Example

iex> Deck.burn(Deck.new(8), 6)
["Ah", "As"]

Returns n_cards from the deck and the rest of the deck.

Example

iex> Deck.deal(Deck.new(8), 2)
{["Kc", "Kd"], ["Kh", "Ks", "Ac", "Ad", "Ah", "As"]}

Returns a full deck of cards (52 cards) ordered by rank.

Examples

iex> Deck.new()
["2c", "2d", "2h", "2s", "3c", "3d", "3h", "3s", "4c", "4d", "4h", "4s",
 "5c", "5d", "5h", "5s", "6c", "6d", "6h", "6s", "7c", "7d", "7h", "7s",
 "8c", "8d", "8h", "8s", "9c", "9d", "9h", "9s", "Tc", "Td", "Th", "Ts",
 "Jc", "Jd", "Jh", "Js", "Qc", "Qd", "Qh", "Qs", "Kc", "Kd", "Kh", "Ks",
 "Ac", "Ad", "Ah", "As"]

Returns a deck containing high n_cards ordered by rank.

n_cards must be less than or equal 52 and must be divisible by 4.

Examples

iex> Deck.new(12)
["Qc", "Qd", "Qh", "Qs", "Kc", "Kd", "Kh", "Ks", "Ac", "Ad", "Ah", "As"]

Returns a deck containing low n_cards ordered by rank.

n_cards must be less than or equal 52 and must be divisible by 4.

Examples

iex> Deck.new_low(12)
["2c", "2d", "2h", "2s", "3c", "3d", "3h", "3s", "4c", "4d", "4h", "4s"]

Shuffles the deck using the modern version of the Fisher–Yates shuffle algorithm.

Examples

iex> deck = Deck.new()
...> shuffled_deck = Deck.shuffle(deck)
...> shuffled_deck != deck
true
iex> Deck.shuffle(shuffled_deck) != Deck.shuffle(shuffled_deck)
true

Returns a full shuffled deck of cards (52 cards).

Examples

iex> Deck.shuffled() != Deck.new()
true

Returns a shuffled deck containing high n_cards.

n_cards must be less than or equal 52 and must be divisible by 4.

Examples

iex> Deck.shuffled(36) != Deck.new(36)
true

Returns a shuffled deck containing low n_cards.

n_cards must be less than or equal 52 and must be divisible by 4.

Examples

iex> Deck.shuffled_low(36) != Deck.new_low(36)
true

Returns number of cards left in the deck.

Example

iex> Deck.size(Deck.new(12))
12