Get users to write ref mutations themselves.
This commit is contained in:
parent
7aa2271463
commit
a7f7df6f01
@ -24,4 +24,12 @@
|
|||||||
(= "better!!!!!!" (letfn [(exclamator [x] (str x "!"))]
|
(= "better!!!!!!" (letfn [(exclamator [x] (str x "!"))]
|
||||||
(dosync
|
(dosync
|
||||||
(alter the-world ___))
|
(alter the-world ___))
|
||||||
@the-world)))
|
@the-world))
|
||||||
|
|
||||||
|
"Don't forget to do your work in a transaction!"
|
||||||
|
(= 0 (do __
|
||||||
|
@the-world))
|
||||||
|
|
||||||
|
"Functions passed to alter may depend on the data in the ref"
|
||||||
|
(= 20 (do
|
||||||
|
(dosync (alter the-world ___)))))
|
||||||
|
@ -115,8 +115,11 @@
|
|||||||
"\"hello\""
|
"\"hello\""
|
||||||
"\"better\""
|
"\"better\""
|
||||||
"\"better!!!\""
|
"\"better!!!\""
|
||||||
|
'(dosync (ref-set the-world 0))
|
||||||
|
|
||||||
]
|
]
|
||||||
"___" ['(comp exclamator exclamator exclamator)]}
|
"___" ['(comp exclamator exclamator exclamator)
|
||||||
|
'(fn [x] (+ 20 x))]}
|
||||||
})
|
})
|
||||||
|
|
||||||
(defn replace-with [s k replacements]
|
(defn replace-with [s k replacements]
|
||||||
|
Loading…
Reference in New Issue
Block a user