Created
October 8, 2013 18:25
-
-
Save misterspeedy/6889219 to your computer and use it in GitHub Desktop.
Discriminated union to represent the outcomes of comparing two cards.
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
/// The possible outcomes when comparing two Poker hands. | |
type Outcome = Win | Draw | Lose | |
with | |
static member FromRanks (rank1 : Rank) (rank2 : Rank) = | |
let sortValue1, sortValue2 = rank1.SortValue, rank2.SortValue | |
if sortValue1 > sortValue2 then | |
Win | |
elif sortValue1 < sortValue2 then | |
Lose | |
else | |
Draw | |
override o.ToString() = | |
match o with | |
| Win -> "Win" | Draw -> "Draw" | Lose -> "Lose" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment