4
votes

I have a map containing emails and passwords that looks like this...

 {"email1" "password1","email2" "password2","email3" "password3"}

I need to make a map inside a map that will contain email as the keyword(i think i explained it ok,i am a newbie in clojure).

How can i create a map with these values?

 {"email1" {"email1" "password1"},"email2" {"email2" "password2"},"email3" {"email3" "password3"}}

I have tried zipmap but i get vector instead of a map...

 {"email1" ["email1" "password1"],"email2" ["email2" "password2"],"email3" ["email3" "password3"]}
1
Your original map does have "email as the keyword". Why do you want it in the value also? If you have a-map and a-key, then [a-key (a-map a-key)] gets you both. You make the data harder to update, and potentially inconsistent.Thumbnail

1 Answers

5
votes
(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"}}