On Mar 26, 2009, at 2:31 AM, Christophe Grand wrote:

> (def foo {:a 5 :b 7})
> (merge-with #(%2 %1) foo {:a inc :b #(+ 5 %)})
> ;; should return {:a 6 :b 12}

So then we can do this:
(defstruct programmer :name :language :iq)

(defn upgrade [programmer]
   (merge-with #(%2 %1) programmer {:language (fn [_] "Clojure") :iq # 
(+ 10 %)}))

(upgrade (struct programmer "Bob" "C++" 120)) => {:name  
"Bob", :language "Clojure", :iq 130}

Aloha,
David Sletten



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

Reply via email to