Am 07.11.2011 14:02, schrieb Scott Jaderholm: > On Mon, Nov 7, 2011 at 4:27 AM, Dennis Haupt <d.haup...@googlemail.com > <mailto:d.haup...@googlemail.com>> wrote: > > Am 07.11.2011 10:18, schrieb Dennis Haupt: > > > >> > >> > >> In his code I did notice he doesn't use destructing very much. > >> > > > > where would that have been useful? > > defn x [{:keys [foo bar]} param] > > instead of > > defn x [param] > (let [foo (:foo param)...]) > > This > > (defn advance-movement [game-element] > (let [stats (:stats game-element) > position-change (:movement stats) > x-change (:x position-change) > y-change (:y position-change) > with-new-movement > (update-in game-element [:stats :position ] #(translated % > x-change y-change))] > with-new-movement)) > > can be this > > (defn advance-movement [{{{:keys [x y]} :movement} :stats}]
> (update-in game-element [:stats :position ] translated x y)) > > or if you want the docstring to be short > > (defn advance-movement [game-element] > (let [{{{:keys [x y]} :movement} :stats} game-element] > (update-in game-element [:stats :position ] translated x y))) > > Note how you don't need the extra function #(). > > I've also noticed that you name your last result in a let and then > return it. I think it's more common to just return it and not name the > final thing. that's because there once was some code which i deleted. i was too lazy to remove the part in the let :) > > Also sometimes you create a separate let under a let divided maybe only > by side effects, such as in split-up-asteroid. You could use one let and > use _ bindings for side effects. let [_ (println "like this?")] > > -- > 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