I've a nested discriminated union representing a deck of playing cards:
type Symbol =
| Seven
| Eight
| Nine
| Ten
| Jack
| Queen
| King
| Ace
type Card =
| Heart of Symbol
| Diamond of Symbol
| Spade of Symbol
| Club of Symbol
Now I want to write a function returning the value of a given card which in my case is independent of the cards suit:
let GetValue (card : Card) =
match card with
| Heart(Seven) -> 0
| Diamond(Seven) -> 0
| Spade(Seven) -> 0
| Club(Seven) -> 0
...
This is obviously tedious to write. Is there a way to do something like this
let GetValue (card : Card) =
match card with
| _(Seven) | _(Eight) | _(Nine) -> 0
| _(Ten) -> 10
...
Thanks a lot.