Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn n-of-a-kind ;untested
- [n cards]
- (let [ranked (vals (group-by :rank cards)),
- candidates (filter #(>= (count %) n) ranked),
- highest (max-by #(:rank (first c)) candidates)]
- {:cards (take n highest), :remaining candidates}))
- ;untested
- (def pair (partial n-of-a-kind 2))
- (def triple (partial n-of-a-kind 2))
- (def fullhouse4 ;untested
- [cards]
- (when-let [{t :cards, remaining :remaining} (triple cards)]
- (when-let [{p :cards} (pair remaining)]
- (compose t p))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement