Skip to content

Instantly share code, notes, and snippets.

@weissjeffm
Created October 26, 2011 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weissjeffm/1316582 to your computer and use it in GitHub Desktop.
Save weissjeffm/1316582 to your computer and use it in GitHub Desktop.
playing cards
(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