Last active
August 29, 2015 14:19
-
-
Save davidrupp/8ecce770be8cadc77f70 to your computer and use it in GitHub Desktop.
alter-var-root-constantly-3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def thing 1) | |
; general form is | |
; (alter-var-root var-to-be-altered | |
; function-to-apply-to-old-value) | |
(alter-var-root #'thing inc) ; value of thing is now 2 | |
; equivalently ... | |
(alter-var-root #'thing (fn [old-val] (inc old-val))) ; value of thing is now 3 | |
; also equivalently ... | |
(alter-var-root #'thing #(inc %1)) ; value of thing is now 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment