also, i'm sure it's a typo, but the fn you originally posted is missing its argument vector...it won't even compile like that...

Jim


On 21/01/13 20:33, JvJ wrote:
That's it!  Thanks.

On Monday, 21 January 2013 15:28:39 UTC-5, Jim foo.bar wrote:

    ...or you can go all the way, skipping reset! completely:

    (swap! game-objects (fn [objects] (reduce-kv #(assoc % %2
    (update-object
    %3)) {} objects) ))

    Jim

    ps: I've not tested this but i don't see why this approach
    wouldn't work...


    On 21/01/13 20:24, Jim - FooBar(); wrote:
    > use reduce-kv on the original map to save some intermediate vector
    > allocation...something similar has come up recently...
    >
    > (reduce-kv #(assoc % %2 (update-object %3)) {} @game-objects)
    >
    > Jim
    >
    > On 21/01/13 20:21, JvJ wrote:
    >> I'm updating a set of objects stored in a map, and I feel like the
    >> way I'm doing it right now is inefficient.  Is there a better way?
    >>
    >> (defn update-all-objects
    >>   "Updates all game objects."
    >>   (reset! *game-objects*
    >>           (into {}
    >>                 (for [[k v] @*game-objects*]
    >>                   [k (update-object v)]))))
    >> --
    >> You received this message because you are subscribed to the Google
    >> Groups "Clojure" group.
    >> To post to this group, send email to clo...@googlegroups.com
    <javascript:>
    >> Note that posts from new members are moderated - please be patient
    >> with your first post.
    >> To unsubscribe from this group, send email to
    >> clojure+u...@googlegroups.com <javascript:>
    >> For more options, visit this group at
    >> http://groups.google.com/group/clojure?hl=en
    <http://groups.google.com/group/clojure?hl=en>
    >

--
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 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

Reply via email to