4clojure/4clojure — Issue #200: problem 128 sandbox doesn't accept solution
Author: tea-rex
Created: 2011-12-31 14:11:39+00:00
State: open

(def regonize-card
(fn [card]
(letfn [
(to-suit [c]
(case c
\D :diamond
\H :heart
\C :club
\S :spade))
(to-val [c]
(let [value (-> c (int) (- 50))]
(if (< value 8) value
(case c
\T 8 \J 9 \Q 10 \K 11 \A 12)))) ]
(-> {}
(assoc :suit (to-suit (first card)))
(assoc :rank (to-val (second card)))
)))
)

(recognize-card "DQ")
(recognize-card "H5")
(recognize-card "CA")

4clojure responds with: java.security.PrivilegedActionException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.MapEntry (NO_SOURCE_FILE:0)

This code works just fine at the REPL