Dude...that's awesome.  I don't know how I completely missed that. I
must have gotten lazy by the time I got to the end of the API page.

On Mar 18, 8:12 pm, Ken Wesson <kwess...@gmail.com> wrote:
> On Fri, Mar 18, 2011 at 9:04 PM, Nick <npatric...@gmail.com> wrote:
> > I'm looking to do some operations upon the data in an associative
> > structure.  What do you think about this method of hijacking the
> > definition of assoc-in?  Is there some better way to do what I'm doing
> > here?
>
> > user> (defn op-in [op m [k & ks] v]
> >            (if ks
> >                (assoc m k (op-in op (get m k) ks v))
> >                (assoc m k (op (get m k) v))))
> > #'user/op-in
>
> > user> (def union-in (partial op-in clojure.set/union))
> > #'user/union-in
> > user> (union-in {:a [#{1 2}]} [:a 0] #{1 7 8})
> > {:a [#{1 2 7 8}]}
>
> > user> (def conj-in (partial op-in conj))
> > #'user/conj-in
> > user> (conj-in {:a [#{1 2}]} [:a 0] 7)
> > {:a [#{1 2 7}]}
>
> Something wrong with using update-in here?

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

Reply via email to