Changes for clojure.core/alter-var-root

zkim on Sun, 26 Sep 2010
(defn sqr [n] 
  "Squares a number"
  (* n n))

user=> (sqr 5)
25

user=> (alter-var-root 
         (var sqr)                     ; var to alter
         (fn [f]                       ; fn to apply to the var's value
           #(do (println "Squaring" %) ; returns a new fn wrapping old fn
                (f %))))

user=> (sqr 5)
Squaring 5
25
zkim on Sun, 26 Sep 2010
(defn sqr [n] 
  "Squares a number"
  (* n n))

user=> (sqr 5)
25

user=> (alter-var-root 
         (var sqr)                     ; var to alter
         (fn [f]                       ; fn to apply to the var's value
           #(do (println "Squaring" %) ; returns a new fn wrapping old fn
                (f %))))

;; Squaring 5
user=> (sqr 5)
25
fogus on Tue, 07 Sep 2010
(defn sqr [n] 
  "Squares a number"
  (* n n))

(sqr 5)
;=> 25

(alter-var-root 
  (var sqr)                     ; var to alter
  (fn [f]                       ; fn to apply to the var's value
    #(do (println "Squaring" %) ; returns a new fn wrapping old fn
         (f %))))

(sqr 5)
; Squaring 5
;=> 25