;;; ;;; ;;; Poker-hands demonstration ;;; ;;; ;; ;; Matcher definitions ;; (define $suit (algebraic-data-matcher { })) (define $card (matcher {[ [suit (mod 13)] {[ {[x y]}] [ (match-all [{ } (between 1 13)] [(set suit) (set integer)] [[ ] [s n]])]}] [ [] {[ {[]}]}] [$ [something] {[$tgt {tgt}]}]})) ;; ;; A function that determins poker-hands ;; (define $poker-hands (lambda [$cs] (match cs (multiset card) {[ >>>>> ] [ >>>>> ] [ >>>>> ] [ >>>>> ] [ >>>>> ] [ >>>>> ] [ >>>>> ] [ >>>>> ] [>>>>> ]}))) ;; ;; Demonstration code ;; (assert-equal "poker-hands-with-joker 1" (poker-hands { 12> 10> 1> 11>}) ) (assert-equal "poker-hands-with-joker 1" (poker-hands { 1> 2> 1> 2>}) ) (assert-equal "poker-hands-with-joker 1" (poker-hands { 4> 2> 1> 3>}) ) (assert-equal "poker-hands-with-joker 1" (poker-hands { 4> 10> 1> 3>}) )