On Tue, Feb 7, 2012 at 3:28 PM, Manuel Paccagnella <manuel.paccagne...@gmail.com> wrote: > And let's say that I want a function that returns the sum of all :a values > of the something seq. I could write the function in this way: > > (defn do-sum [some-coll] > (reduce + (map #(:a %) some-coll))) > > Not a big deal, but I wonder if there is a better way to do it.
One better way: (defn do-sum [some-coll] (reduce + (map :a some-coll))) Keywords can be used as functions. That's probably tidy enough not to feel the need to do something else, such as destructuring. -- 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