Hi folks It may seem silly question but why when I doseq over a vector that is wrapped in an atom and change the vector using swap! while I am inside doseq, the doseq sets to the beginning of the vector intermittently:
(def a-data (atom [15 9 8 1 4 11 7 12 13 14 5 3 16 2 10 6])) (defn switch-two-elements [the-vector] ... ) ;; swaping two elements in given vector (doseq [element @a-data] (println @a-data) (println element) (swap! a-data switch-two-elements)) [15 9 8 1 4 11 7 12 13 14 5 3 16 2 10 6] 15 [1 9 8 15 4 11 7 12 13 14 5 3 16 2 10 6] 9 [1 4 8 15 9 11 7 12 13 14 5 3 16 2 10 6] 8 [1 4 5 15 9 11 7 12 13 14 8 3 16 2 10 6] 1 ==> I expect this to be 15 I suspect the reason would be the same as the one behind not changing a collection in java while iterating over it. I appreciate any insight on this. Thanks a lot Best regards -- Software Architect & Computer Scientist -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.