vary-meta

clojure.core

  • (vary-meta obj f & args)
Returns an object of the same type and value as obj, with
(apply f (meta obj) args) as its metadata.

2 Examples top

  • user=> (meta (vary-meta 'foo assoc :a 1))
    {:a 1}
    
  • ;; continuing from the previous with-meta example
    user=> (def wm (with-meta [1 2 3] {:my "meta"}))
    #'user/wm
    
    user=> wm
    [1 2 3]
    
    user=> (meta wm)
    {:my "meta"}
    
    user=> (def new-wm (vary-meta wm assoc :your "new meta"))
    #'user/new-wm
    
    user=> new-wm
    [1 2 3]
    
    user=> (meta new-wm)
    {:my "meta", :your "new meta"}
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:610 top

(defn vary-meta
 "Returns an object of the same type and value as obj, with
  (apply f (meta obj) args) as its metadata."
 {:added "1.0"
   :static true}
 [obj f & args]
  (with-meta obj (apply f (meta obj) args)))
Vars in clojure.core/vary-meta:
Used in 0 other vars

Comments top

No comments for vary-meta. Log in to add a comment.