You could use assoc-in...

(def rms (ref {:key1 {:key2 {:key3 #{}}}}))

(dosync (alter rms assoc-in [:key1 :key2 :key3] "foo"))
{:key1 {:key2 {:key3 "foo"}}}

Rgds, Adrian.

On Sun, Jul 5, 2009 at 6:07 AM, Rowdy Rednose <rowdy.redn...@gmx.net> wrote:

>
> Say I have a data structure like this
>
> (def ref-map-map-map-set (ref {:key1 {:key2 {:key3 #{}}}}))
>
> If I want to add a new member to the set which is the value of :key3,
> I currently do this:
>
> (dosync
>  (let [key1 (:key1 @ref-map-map-map-set)
>       key2 (:key2 key1)
>       key3 (:key3 key2)]
>   (ref-set ref-map-map-map-set (assoc @ref-map-map-map-set :key1
> (assoc key1 :key2 (assoc key2 :key3 (conj key3 new-member)))))))
>
> Do I really have to assoc all the way through to the inner map? Isn't
> there a more succinct way to write this? In Common Lisp there's (setf
> (getf ...))
> >
>

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