0
datatype cards = king of int * int
| queen of string
| jack of cards
| ace of cards * cards
| joker of int * cards
datatype cards = king of int * int
| queen of string
| jack of cards
| ace of cards * cards
| joker of int * cards
Sicher.
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
Allerdings würde ich meinen Wert Konstrukteure in Groß nennt sie von Funktionen zu unterscheiden:
datatype cards = King of int * int
| Queen of string
| Jack of cards
| Ace of cards * cards
| Joker of int * cards
Scheint wie ein Datentyp für ein ernst seltsames Kartenspiel. Hat es irgendeine Motivation? –