Created
October 7, 2013 18:21
-
-
Save misterspeedy/6872555 to your computer and use it in GitHub Desktop.
Representing a card suit as a Discriminated Union.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// A card suit. | |
| type Suit = | |
| | Club | Diamond | Heart | Spade | |
| static member FromChar c = | |
| match c with | |
| | '♣' -> Club | '♦' -> Diamond | '♥' -> Heart | '♠' -> Spade | |
| | _ -> raise (ArgumentException(sprintf "Invalid suit character: %c" c)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment