user=> (def foo {:a 5 :b 7})
#'user/foo
user=> (update-in foo [:a] inc)
{:a 6, :b 7}
user=>On Wed, Mar 25, 2009 at 11:27 PM, kinghajj <[email protected]> wrote: > > If not, I think it's pretty useful. There should be an easy way to > apply functions to maps' values by keys. > > (defn update > [m & keyfuns] > (let [[key fun & rest] keyfuns] > (if (and key fun) > (recur (assoc m key (fun (key m))) rest) > m))) > > (def foo {:a 5 :b 7}) > (def bar (update foo :a inc :b #(+ 5 %))) > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
