On Sat, 20 Feb 2010 17:27:34 -0800 (PST)
"[email protected]" <[email protected]> wrote:
> Hi :
>
> Say, I have a (def *a (ref {:b [{:c 5}]})) .
> I want to add 1 to the :c inside, how would I write?
> (Note: the value 5 is in (:b 0 :c), while 0 is the array index)
>
> (dosync (alter *a ______ )) ; please help me fill the blank.
>
> Someone mention I can use the zipper library or the walker library,
> but after I checked I still have no idea how to make it.
Your blank should be update-in [:b 0 :c] inc, so the whole thing is:
(dosync (alter *a update-in [:b 0 :c] inc))
<mike
--
Mike Meyer <[email protected]> http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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