Created
January 7, 2013 00:20
-
-
Save anonymous/4471273 to your computer and use it in GitHub Desktop.
This file contains 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 players | |
[{:id 1 :health 100} {:id 2 :health 90}]) | |
(def game | |
{:players players}) | |
(def current-game | |
(atom game)) | |
(defn kill-player | |
[player] | |
(assoc player :health 0)) | |
(defn kill-players | |
[players] | |
(map kill-player players)) | |
;; Is using @ inside the swap! a bad idea? | |
;; In any case, these seems really verbose. | |
(defn kill-players! | |
[game-atom] | |
(swap! game-atom assoc :players (kill-players (:players @game-atom)))) | |
(kill-players! current-game) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment