We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(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
The text was updated successfully, but these errors were encountered:
The sandbox doesn't allow the use of case but you're basically doing a hash-map lookup, so you can rework it like so:
(fn [card] (letfn [(to-suit [c] (get {\D :diamond \H :heart \C :club \S :spade} c)) (to-val [c] (let [value (-> c (int) (- 50))] (if (< value 8) value (get {\T 8 \J 9 \Q 10 \K 11 \A 12} c))))] {:suit (to-suit (first card)) :rank (to-val (second card))}))
Hope this helps!
Sorry, something went wrong.
No branches or pull requests
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
The text was updated successfully, but these errors were encountered: