On Mar 19, 2012, at 5:31 PM, Michael Gardner wrote: > Or the simplest option: just have your functions return nil to indicate that > the world state should remain unchanged from its previous value.
If your world state is a hash-map, you could also return partial states and merge them into the existing world; that would make nil automatically mean "no change". Let's say your world has the key :player (among other things): (defn move-player [{:keys [player ...]} ...] (when (can-move player) {:player (assoc player ...)})) The above returns nil when (can-move player) returns false; otherwise it returns a hash-map with only the key :player defined. Then (merge world (move-player world ...)) does the right thing, with no special-casing of nil needed. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en