I believe I am having trouble destructuring a map in core.logic. I have the following code:
... used clojure.core.logic
... required clojure.core.logic.arithmetic as logic.arithmetic.
(def hand ({:rank 9, :suit :hearts}
{:rank 13, :suit :clubs}
{:rank 6, :suit :spades}
{:rank 8, :suit :hearts}
{:rank 12, :suit :clubs}))
(run* [q]
(fresh [v w x y z] ;;cards
(== q [v w x y z])
(membero v hand)
(membero w hand)
(membero x hand)
(membero y hand)
(membero z hand)
(fresh [a b c d e] ;;ranks
(== {:rank a} v)
(== {:rank b} w)
(== {:rank c} x)
(== {:rank d} y)
(== {:rank e} z)
(logic.arithmetic/>= a b)
(logic.arithmetic/>= b c)
(logic.arithmetic/>= c d)
(logic.arithmetic/>= d e))
(distincto q)))
It returns the empty list (), indicating that it found no matches. I believe it is a problem in the (== {:rank a} v) portion of the code. I am attempting to simply return q, where q is a vector of the maps in :rank descending order.