2014-01-26 00:04:22 +00:00
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "In the beginning, there was a word"
|
2010-11-10 02:19:10 +00:00
|
|
|
(= __ (deref the-world))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "You can get the word more succinctly, but it's the same"
|
2010-11-10 02:19:10 +00:00
|
|
|
(= __ @the-world)
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "You can be the change you wish to see in the world."
|
2010-11-10 02:19:10 +00:00
|
|
|
(= __ (do
|
|
|
|
|
(dosync (ref-set the-world "better"))
|
|
|
|
|
@the-world))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Alter where you need not replace"
|
2010-11-10 02:19:10 +00:00
|
|
|
(= __ (let [exclamator (fn [x] (str x "!"))]
|
|
|
|
|
(dosync
|
2011-10-26 02:55:54 +00:00
|
|
|
(alter the-world exclamator)
|
|
|
|
|
(alter the-world exclamator)
|
|
|
|
|
(alter the-world exclamator))
|
2010-11-10 02:19:10 +00:00
|
|
|
@the-world))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Don't forget to do your work in a transaction!"
|
2010-11-11 01:16:50 +00:00
|
|
|
(= 0 (do __
|
2011-10-26 02:55:54 +00:00
|
|
|
@the-world))
|
2010-11-11 01:16:50 +00:00
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Functions passed to alter may depend on the data in the ref"
|
2010-11-11 01:16:50 +00:00
|
|
|
(= 20 (do
|
2011-03-31 12:24:09 +00:00
|
|
|
(dosync (alter the-world ___))))
|
|
|
|
|
|
2016-02-27 02:33:05 +00:00
|
|
|
; "Two worlds are better than one"
|
2011-03-31 12:24:09 +00:00
|
|
|
(= ["Real Jerry" "Bizarro Jerry"]
|
2011-10-26 02:55:54 +00:00
|
|
|
(do
|
|
|
|
|
(dosync
|
|
|
|
|
(ref-set the-world {})
|
|
|
|
|
(alter the-world assoc :jerry "Real Jerry")
|
|
|
|
|
(alter bizarro-world assoc :jerry "Bizarro Jerry")
|
2016-02-27 02:33:05 +00:00
|
|
|
__)))
|