Implement comparator functions for ranks, suits and cards.

This commit is contained in:
2025-02-14 17:17:58 +00:00
parent 3906be4d59
commit 9ab585d7af
2 changed files with 14 additions and 1 deletions

View File

@@ -76,3 +76,15 @@
(->> (suit->int suit)
(* 13)
(+ (rank->int rank)))))
(fn suit< (s1 s2) (-> (suit suit) boolean)
(< (suit->int s1) (suit->int s2)))
(fn rank< (r1 r2) (-> (rank rank) boolean)
(< (rank->int r1) (rank->int r2)))
(fn card< (c1 c2) (-> (card card) boolean)
(destructuring-bind ((r1 . s1) (r2 . s2)) (list c1 c2)
(if (eq r1 r2)
(suit< s1 s2)
(rank< r1 r2))))

View File

@@ -40,7 +40,8 @@
;; Converters
:int->suit :int->rank :int->card
:suit->int :rank->int :card->int
))
;; Comparators
:suit< :rank< :card<))
(defpackage cantedraw.main
(:use :cl :cantedraw.lib.macros :cantedraw.lib.functions)