Finished koan 17
This commit is contained in:
parent
12a5b7aaec
commit
ab7536f8da
1 changed files with 7 additions and 7 deletions
|
|
@ -5,29 +5,29 @@
|
|||
|
||||
(meditations
|
||||
"Atoms are like refs"
|
||||
(= __ @atomic-clock)
|
||||
(= 0 @atomic-clock)
|
||||
|
||||
"You can change at the swap meet"
|
||||
(= __ (do
|
||||
(= 1 (do
|
||||
(swap! atomic-clock inc)
|
||||
@atomic-clock))
|
||||
|
||||
"Keep taxes out of this: swapping requires no transaction"
|
||||
(= 5 (do
|
||||
__
|
||||
(= 5 (do
|
||||
(swap! atomic-clock + 4)
|
||||
@atomic-clock))
|
||||
|
||||
"Any number of arguments might happen during a swap"
|
||||
(= __ (do
|
||||
(= 20 (do
|
||||
(swap! atomic-clock + 1 2 3 4 5)
|
||||
@atomic-clock))
|
||||
|
||||
"Atomic atoms are atomic"
|
||||
(= __ (do
|
||||
(= 20 (do
|
||||
(compare-and-set! atomic-clock 100 :fin)
|
||||
@atomic-clock))
|
||||
|
||||
"When your expectations are aligned with reality, things proceed that way"
|
||||
(= :fin (do
|
||||
(compare-and-set! __ __ __)
|
||||
(compare-and-set! atomic-clock 20 :fin)
|
||||
@atomic-clock)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue