Ok after a cup of tea I'm starting to realize i can easily do something like:

(let [moved (update-position p coords)] ;no mutation - returns a new piece
(filter (complement dead?)
(-> board
(dissoc (getListPosition p)) ;get rid of the old piece
   (assoc  (getListPosition moved) moved))))  ;shove in the new one


and this will take care of dead-pieces concisely as well...

Jim

On 13/06/12 17:55, Jim - FooBar(); wrote:
On 13/06/12 17:22, [email protected] wrote:
For example, if your state were a vector [:x :o :x nil .... :x]
(for a board of tic-tac-toe), calling (assoc board 3 :x) will return a
new board
with the position 3 set to :x.

Yes but in tic-tac-toe you are inserting pieces while in chess/checkers you move pieces...that is, pieces disappear from their original position and move to the next. Using your recommendation I would have to do at least 1 dissoc and 1 assoc for a single move won't I? on the other hand, with your approach it means I don't have to build a new board after each move - it happens automatically...

by the way, and I'm not trying to argue here...trying to make constructive conversation! I don't have a lot of people I can talk with about these things...thanks :-)

Jim

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to