Last active
December 30, 2015 02:19
-
-
Save prozz/7761701 to your computer and use it in GitHub Desktop.
clojure adventures
This file contains 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
how to get from [{:text "AAA", :code "0011"}] to {11 {:text "AAA", :code "0011"}} | |
note that key in result is made with use of following function: | |
=> (code->int "00123") | |
123 | |
=> (def t [{:code "0011" :text "AAA"}]) | |
[{:text "AAA", :code "0011"}] | |
=> (into {} (map identity t)) | |
{:text "AAA", :code "0011"} | |
=> (into {} (map :code t)) | |
ClassCastException java.lang.Character cannot be cast to java.util.Map$Entry clojure.lang.ATransientMap.conj (ATransientMap.java:44) | |
=> (into {} (map (juxt :code) t)) | |
IllegalArgumentException Vector arg to map conj must be a pair clojure.lang.ATransientMap.conj (ATransientMap.java:37) | |
=> (into {} (map (juxt :code identity) t)) | |
{"0011" {:text "AAA", :code "0011"}} | |
=> (into {} (map (juxt (comp code->int :code) identity) t)) | |
{11 {:text "AAA", :code "0011"}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment