On Friday, April 20, 2012 9:07:49 AM UTC-5, Walter van der Laan wrote: > > You could start with pure functions to handle the game logic, e.g.: > > (defn new-game [] > [[\- \- \-] > [\- \- \-] > [\- \- \-]]) > > (defn print-game [game] > (doseq [row game] > (println (apply str row)))) > > (defn move [game mark pos] > (assoc-in game pos mark)) > > (print-game (new-game)) > (print-game (move (new-game) \x [1 1])) > (print-game (-> (new-game) (move \x [1 1]) (move \o [0 2]))) >
Right, but then I'm having to keep track of the moves and reapply them on every game update, right? I guess my question is more conceptual (so that I can gain an understanding of Clojure), I don't really care about tic tac toe, what I really care about is how to maintain mutable state. > -- 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