;;; ;;; ;;; Poker-hands demonstration ;;; ;;; ;; ;; Matcher definitions ;; (define $suit (algebraic-data-matcher { })) (define $card (algebraic-data-matcher {})) ;; ;; A function that determines poker-hands ;; (define $poker-hands (lambda [$cs] (match cs (multiset card) {[ >>>>> "Straight flush"] [ >>>>> "Four of a kind"] [ >>>>> "Full house"] [ >>>>> "Flush"] [ >>>>> "Straight"] [ >>>>> "Three of a kind"] [ >>>>> "Two pair"] [ >>>>> "One pair"] [>>>>> "Nothing"]}))) ;; ;; Demonstration code ;; (test (poker-hands { 12> 10> 13> 1> 11>})) (test (poker-hands { 1> 2> 1> 1> 2>})) (test (poker-hands { 4> 2> 5> 1> 3>})) (test (poker-hands { 4> 10> 5> 1> 3>}))