Skip to content

Instantly share code, notes, and snippets.

Created January 7, 2013 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/4471273 to your computer and use it in GitHub Desktop.
Save anonymous/4471273 to your computer and use it in GitHub Desktop.
(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