;;; ;;; ;;; 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 ;; (assert-equal "poker hands 1" (poker-hands { 12> 10> 13> 1> 11>}) "Straight flush") (assert-equal "poker hands 2" (poker-hands { 1> 2> 1> 1> 2>}) "Full house") (assert-equal "poker hands 3" (poker-hands { 4> 2> 5> 1> 3>}) "Straight") (assert-equal "poker hands 4" (poker-hands { 4> 10> 5> 1> 3>}) "Nothing")