aboutsummaryrefslogtreecommitdiff
path: root/model.lisp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2025-02-14 17:17:58 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2025-02-14 17:17:58 +0000
commit9ab585d7affcfde2c48c6b52cb2d73953e95d428 (patch)
treecbc1943227d7518e628ae5f8a85f1662b82b69dd /model.lisp
parent3906be4d590ce740250bac2bd49b45129a32bb2b (diff)
downloadcantedraw-9ab585d7affcfde2c48c6b52cb2d73953e95d428.tar.gz
cantedraw-9ab585d7affcfde2c48c6b52cb2d73953e95d428.tar.bz2
cantedraw-9ab585d7affcfde2c48c6b52cb2d73953e95d428.zip
Implement comparator functions for ranks, suits and cards.
Diffstat (limited to 'model.lisp')
-rw-r--r--model.lisp12
1 files changed, 12 insertions, 0 deletions
diff --git a/model.lisp b/model.lisp
index a93cf6e..068844b 100644
--- a/model.lisp
+++ b/model.lisp
@@ -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))))