Re: On section 11.2.1 of /The Joy of Clojure/

2012-01-31 Thread Herbert Euler
Hmm, I didn't read the definition of `board-map' carefully. It seems the second form (dosync (board-map deref board)) is the best among the three, as it views `board' as a whole. The other two might have the potential problem of printing incoordinated values of entries in `board', i.e. the e

Re: On section 11.2.1 of /The Joy of Clojure/

2012-01-31 Thread Herbert Euler
I think I'm right. This is a program that demonstrates what I was thinking o: ;; Program begins. (defn traverse [f dat] (vec (map #(f %) dat))) (def data (traverse ref (take 10 (iterate inc 0 (-> (fn [] (dosync (loop [i 0 data data] (when (seq d

On section 11.2.1 of /The Joy of Clojure/

2012-01-31 Thread Guanpeng Xu
Hi all, In section 11.2.1 of the book /The Joy of Clojure/, the author shows the effect of `dosync' by starting 100 threads and then watching the value of a Ref: (go make-move 100 100) (board-map #(dosync (deref %)) board) Here, the first `go' form starts 100 threads, their effect is modifyi