at other place ,i use (swap! map-1 assoc key value)
在 2014年7月16日星期三UTC+8上午11时20分11秒,Baishampayan Ghose写道:
>
> Atoms are not coordinated, so you need to use refs here:
>
> (def map-1 (ref {}))
> (def map-2 (ref {}))
>
> (defn change [key1 key2 ]
> (dosync
> (alter map-1 dissoc key1)
> (alter map-2 dissoc key2)))
>
> Depending on your problem you might consider using just one ref instead of
> two as well (in that case, an atom should be fine).
>
> ~BG
>
>
> On Wed, Jul 16, 2014 at 8:41 AM, zhenxuanpan <[email protected]
> <javascript:>> wrote:
>
>> (def map-1 (atom {}))
>> (def map-2 (atom {}))
>>
>> (defn change [key1 key2 ]
>> (dosync
>> (swap! map-1 dissoc key1)
>> (swap! map-2 dissoc key2)
>> )
>> )
>>
>> is this way ok ?
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> <javascript:>
>> 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] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Baishampayan Ghose
> b.ghose at gmail.com
>
--
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.