How to transform a list of maps
(def item1 ({:tag1 "val1" ,:tag2 "val2"} {:tag1 "val3" :tag2 "val2"}))
to vector of maps. The result should be
[{:tag1 "val1" ,:tag2 "val2"} {:tag1 "val3" :tag2 "val2"}]
I think what you are looking for is the vec
function.
(def item1 '({:tag1 "val1" ,:tag2 "val2"} {:tag1 "val3" :tag2 "val2"}))
(vec item1)
;= [{:tag1 "val1", :tag2 "val2"} {:tag1 "val3", :tag2 "val2"}]
Note that you were missing a quote on your list of maps, otherwise since maps can take the function position, you are applying the second map to the first one (ie (map key)
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.