1.3.0 permalink Arrow_down_16x16

rename

clojure.set

  • (rename xrel kmap)
Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap

1 Example top

  • ;; Here's a relation with two keys (think "column names" in SQL), :a and :b
    
    user=> (def relation #{  {:a 1, :b 1}  {:a 2, :b 2} })
    
    
    ;; I decide that :a is a stupid name and that :new-a would be better. 
    ;; Here's how I make a new relation with the renamed key:
    
    user=> (rename relation {:a :new-a})
    #{{:new-a 1, :b 1} {:new-a 2, :b 2}}
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/set.clj:89 top

(defn rename
  "Returns a rel of the maps in xrel with the keys in kmap renamed to the vals in kmap"
  {:added "1.0"}
  [xrel kmap]
    (set (map #(rename-keys % kmap) xrel)))
Vars in clojure.set/rename:
Used in 0 other vars

Comments top

No comments for rename. Log in to add a comment.