You're viewing version 1.2.0 of vary-meta. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

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:550 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"}
 [obj f & args]
  (with-meta obj (apply f (meta obj) args)))
Vars in clojure.core/vary-meta: apply defn meta with-meta

Comments top

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