Say I've got this map of keys to integer values: (def m {:one 0 :two 0 :three 0})
I want to write a function "inc-values-in-map" that takes such a map, a collection of keys and will increment those keys' values in the map. In other words, calling (inc-values-in-map m [:one :three]) should return {:one 1, :two 0, :three 1} I've come up with this: (defn inc-values-in-map [map keys] (merge-with + map (zipmap keys (repeat 1)))) Aren't there more elegant ways to implement this function? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---