Created
October 26, 2011 14:51
-
-
Save weissjeffm/1316582 to your computer and use it in GitHub Desktop.
playing cards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fn [s] | |
(let [suit (first s) rank (last s) | |
st (case suit | |
\D :diamond | |
\C :club | |
\S :spade) | |
rk (try | |
(- (Integer/parseInt rank) 2) | |
(catch NumberFormatException e | |
(case rank | |
\T 8 | |
\J 9 | |
\Q 10 | |
\K 11 | |
\A 12)))] | |
{:suit st | |
:rank rk})) | |
;; 4clojure | |
; "You tripped the alarm! catch is bad!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment