store/[org.clojure/clojure "1.8.0"] clj::clojure.core/alter

Official Documentation

Add notes
Arities
==================================================
   [ref fun & args]

Docstring
==================================================
  Must be called in a transaction. Sets the in-transaction-value of
  ref to:

  (apply fun in-transaction-value-of-ref args)

  and returns the in-transaction-value of ref.

Source

(defn alter
  "Must be called in a transaction. Sets the in-transaction-value of
  ref to:

  (apply fun in-transaction-value-of-ref args)

  and returns the in-transaction-value of ref."
  {:added "1.0"
   :static true}
  [^clojure.lang.Ref ref fun & args]
    (. ref (alter fun args)))

Example 1

Edit
;; alter is a way to change the value of a reference.

;; Here we're defining a ref named 'names' and setting its value to
;; an empty vector.
(def names (ref []))
;; => #'user/names

;; A function to add a name to the vector (notice the meat's wrapped
;; in a dosync
(defn add-name [name]
  (dosync
   (alter names conj name)))
;; => #'user/add-name

(add-name "zack")
;; => ["zack"]

(add-name "shelley")
;; => ["zack" "shelley"]

;; Notice that the var 'names' points to the reference that we created
(println names)
;; > #<Ref@658ba380: [zack shelley]>
;; => nil

;; To get the actual value of the ref, you use the '@' symbol, or deref
(println @names)
;; > [zack shelley]
;; => nil

(println (deref names))
;; > [zack shelley]
;; => nil

Uses on crossclj