datatype cards = king of int * int
| queen of string
| jack of cards
| ace of cards * cards
| joker of int * cards
Asked
Active
Viewed 58 times
0

sshine
- 15,635
- 1
- 41
- 66

Ronchi Floyd
- 1
- 1
-
2Seems like a data type for a seriously strange card game. Does it have any motivation? – John Coleman Mar 31 '16 at 10:23
1 Answers
2
Sure.
fun hasKing cards =
case cards of
king (i, j) => true
| queen s => false
| jack cards1 => hasKing cards1
| ace (cards1, cards2) => hasKing cards1 orelse hasKing cards2
| joker (i, cards2) => hasKing cards2
However, I would name my value constructors in uppercase to differentiate them from functions:
datatype cards = King of int * int
| Queen of string
| Jack of cards
| Ace of cards * cards
| Joker of int * cards

sshine
- 15,635
- 1
- 41
- 66