A package for representing playing cards for card games.
1 Star
Updated Last
1 Year Ago
Started In
March 2021


Docs Build docs build
Documentation dev
GHA CI gha ci
Code Coverage codecov
Bors enabled bors

A package for representing playing cards for card games (for a standard deck of fifty two).


A playing Card is consists of a rank:

  • Rank(N::Int) where 1 ≤ N ≤ 13 where
  • N = 1 represents an Ace (which can have high or low values via high_value and low_value)
  • N = 11 represents a Jack
  • N = 12 represents a Queen
  • N = 13 represents a King

and a suit:

  • (Club)
  • (Spade)
  • (Heart)
  • (Diamond)

The value of the rank can be retrieved from high_value and low_value:

  • high_value(c::Card) == low_value(c::Card) == c.rank
  • high_value(::Card) = 14 for Ace
  • low_value(::Card) = 1 for Ace

Cards have convenience constructors and methods for extracting information about them:

julia> using PlayingCards

julia> card = A♡

julia> string(card)

julia> suit(A♡)

julia> rank(A♠)

julia> high_value(A♢)

julia> high_value(J♣)

julia> low_value(A♡)


A Deck is a struct with a Vector of Cards, which has a few convenience methods:

julia> using PlayingCards

julia> deck = ordered_deck()
A♣ 23456789♣  T♣  J♣  Q♣  K♣
A♠ 23456789♠  T♠  J♠  Q♠  K♠
A♡ 23456789♡  T♡  J♡  Q♡  K♡
A♢ 23456789♢  T♢  J♢  Q♢  K♢

julia> shuffle!(deck)

julia> hand = pop!(deck, 2)
(5♣, 8♢)

julia> deck
Q♣  T♣  5♢  K♠  J♢  4♢  T♡  K♢  25288♠
K♣  T♠  A♣  Q♠  Q♢  276♣  J♡  96♢  A♢  7♠
A♡  7337♢  J♠  54943♠  J♣  696♠  T♢  3♡  A♠  8♡  K♡  24♠  Q♡  9


Some ideas used here were inspired by

Required Packages

No packages found.

Used By Packages