Skip to content

Instantly share code, notes, and snippets.

@timvw
Created December 11, 2013 06:56
Show Gist options
  • Save timvw/7906093 to your computer and use it in GitHub Desktop.
Save timvw/7906093 to your computer and use it in GitHub Desktop.
Cards
type Suit =
| Spades
| Hearts
| Diamonds
| Clubs
type Rank =
| Ace
| King
| Queen
| Jack
| Number of int
type Card = {
Suit : Suit
Rank : Rank
}
let suits = [Spades; Hearts; Diamonds; Clubs]
let ranks = ([2..10] |> List.map (fun n -> Number n)) @ [Jack; Queen; King; Ace]
let deck =
suits
|> List.collect (fun suit ->
ranks |> List.map (fun rank -> { Suit = suit; Rank = rank; }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment