Reputation: 163
I have the following structure
(def aaa '({:a "read" :b "one"} {:a "open" :b "two"}) )
I need to rename all :a keys for example to :c and I want to get
({:c "read" :b "one"} {:c "open" :b "two"})
Upvotes: 5
Views: 2258
Reputation: 506
You are looking for clojure.set
's rename-keys function.
Used with map
, you'll get the result you want:
(map #(clojure.set/rename-keys % {:a :c}) [{:a "read" :b "one"} {:a "open" :b "two"}])
=> ({:b "one", :c "read"} {:b "two", :c "open"})
Upvotes: 10