Функции

;; a parameter cannot be changed in Clojure: there is no "inout" or "ref".
;; a function that has two answers returns them in a vector
(defn swapped [s1 s2]
  [s2 s1])

(let [[s1 s2] (swapped "A" "B")]
  (println (str "s1 is " s1 ", s2 is " s2)))

;; when the change really must be seen by everyone, the mutable cell
;; is explicit: an atom is passed in and updated in place
(defn swap-cells! [a b]
  (let [tmp @a]
    (reset! a @b)
    (reset! b tmp)))

(def a (atom "A"))
(def b (atom "B"))
(swap-cells! a b)
(println (str "a is " @a ", b is " @b))