我有一张包含电子邮件和密码的地图,如下所示......
{"email1" "password1","email2" "password2","email3" "password3"}
我需要在地图中制作一个地图,其中包含电子邮件作为关键字(我想我解释不错,我是clojure的新手)。
如何使用这些值创建地图?
{"email1" {"email1" "password1"},"email2" {"email2" "password2"},"email3" {"email3" "password3"}}
我尝试过zipmap但是我得到了矢量而不是地图......
{"email1" ["email1" "password1"],"email2" ["email2" "password2"],"email3" ["email3" "password3"]}
答案 0 :(得分:3)
(def m {"email1" "password1","email2" "password2","email3" "password3"})
(into {} (map (fn [[k v]] [k {k v}]) m))
;= {"email2" {"email2" "password2"}, "email1" {"email1" "password1"}, "email3" {"email3" "password3"}}