On Fri, Jan 22, 2010 at 8:57 AM, Chouser <chou...@gmail.com> wrote: > On Thu, Jan 21, 2010 at 10:11 PM, Sean Devlin <francoisdev...@gmail.com> > wrote: >> Sometimes you don't want assoc-in to create a hash-map. Sometimes you >> wish it could create a sorted map. >> >> Just finished working on something with Alexy Khrabrov & Chouser on >> IRC, and the three of us are wondering if the result might be >> generally useful. >> >> (defn assoc-in-with >> "supply a default-map instead of a hash-map" >> [m default-map [k & ks] v] >> (if ks >> (assoc m k (assoc-in-as (get m k default-map) default-map ks v)) >> (assoc m k v))) > > As I mentioned in IRC, this could actually be a 4-argument > version of 'assoc-in' instead of a new function. Assuming of > course Rich likes the idea. >
Where would the default go? Also, need it be a map, vs anything associative (e.g. a vector)? Rich -- 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