Order of keys and values in maps
When we call keys on a map, is the order of keys in the resulting seq guaranteed to be the same as the order of values when we call vals on the same ma开发者_运维知识库p?
In other words, is it ok to map a function f over the contents of a map like this:
(map #(f %1 %2) (keys m) (vals m))
If not, is there an equivalent to perl's each in clojure? Or perhaps the inverse function of zipmap?
You can iterate over the map, you get key val pairs,
(map (fn [[key val]]
(println key val)) {:a :b :c :d})
pretty much all clojure data structures are seqable.
精彩评论