Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constructing a map from a vector in Clojure

Tags:

clojure

I have a vector that looks like this:

["Config" "{}" "Auth" "{}" "Other" "{}"]

I'd like to take each key value pair and turn it into the following map:

{"Config" "{}", "Auth" "{}", "Other" "{}"}

How can I do this with Clojure? Is there a built in function that does this?

like image 610
Brad Koch Avatar asked Aug 29 '13 14:08

Brad Koch


1 Answers

Use apply to apply the map constructor of desired type to the vector, ie :

(apply hash-map ["Config" "{}" "Auth" "{}" "Other" "{}"])

edit

According to this answer you can get different map types depending on the way you evaluate {}, so use the map constructor suitable to your needs.

edit

Looking at this the different object types returned by literal {} appears to be a bug.

like image 138
soulcheck Avatar answered Sep 30 '22 08:09

soulcheck