5
votes

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?

1
Just got an answer already, (apply assoc {} ["Config" "{}" "Auth" "{}" "Other" "{}"]). Is there one better? - Brad Koch

1 Answers

6
votes

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.