On Apr 1, 6:57 am, Korny Sietsma <ko...@sietsma.com> wrote: > I have a world that is a list of structures > > The world itself will change occasionally - i.e. I'll add or remove > structures from the overall list, and I'll regularly be reading the whole > list.
> (C) both of the above - a ref for the "world" list which itself contains a > list of refs to each structure I believe this is the way to go. Compare it with Rich's ants colony simulation (<a href="http://clojure.googlegroups.com/web/ants.clj? gda=wt5HfzoAAAC2LrkjeC7f10uHiY7GOiyxxoot- tFsZ2hOJiGaR1IofO9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0">ants.clj</ a>. He defines a 2D world of refs: ;world is a 2d vector of refs to cells (def world (let [mk_vec (fn [x] (apply vector x)) mk_cell (fn [_] (ref (struct cell 0 0))) dim_seq (range dim)] ;(0,...,dim) (mk_vec (map (fn [_] (mk_vec (map mk_cell dim_seq))) dim_seq)))) Your case is simpler since you just need a single array: (def dim 42);initial world size (def world (let [mk_vec (fn [x] (apply vector x)) mk_cell (fn [_] (ref (struct cell 0 0))) ;;replace with your struct dim_seq (range dim)] ;(0,...,dim) (mk_vec (map mk_cell dim_seq))) ;;note I didn't test this code I think this would work for you. -- Karl --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---