ahh,... I see.
Thank you all - you've been very helpful.
Trevor
On Sep 14, 12:31 am, Stuart Campbell wrote:
> I knew there must be a nicer way to write that :)
>
> On 14 September 2011 16:22, Meikel Brandmeyer (kotarak) wrote:
>
>
>
>
>
>
>
> > Or:
>
> > (swap! user-queues update-in [k] (fnil
I knew there must be a nicer way to write that :)
On 14 September 2011 16:22, Meikel Brandmeyer (kotarak) wrote:
> Or:
>
> (swap! user-queues update-in [k] (fnil conj
> clojure.lang.PersistentQueue/EMPTY) v)
>
> Sincerely
> Meikel
>
> --
> You received this message because you are subscribed to
Or:
(swap! user-queues update-in [k] (fnil conj
clojure.lang.PersistentQueue/EMPTY) v)
Sincerely
Meikel
--
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 a
Hi Trevor,
I hope I've understood your problem correctly.
You can modify nested structures using e.g. update-in:
(let [k "user1" v 1234]
(swap! user-queues update-in k conj v))
That's assuming that a user queue already exists in the map. If it doesn't,
you could do something like:
(let
Thanks for the quick responses.
I'll try to answer Andy's question: "How do you know, in advance, that
it doesn't need to handle such concurrent changes?" ... and at the
same time I will try to provide this example to Stuart, hoping I can
see how using a map inside an atom might work:
Let's say m
> For example, what if I have a hash-map that needs to handle concurrent
> changes to the data structure, but never needs to have concurrent
> changes to a given piece of data (i.e a key/value pair). Wouldn't
> there be value in being able to modify the data "in-place" without
> making a copy, or n
To my knowledge, there are no built-in data structures that are mutable and
that use the same access functions.
There are built-in data structures called transients that are mutable, and
use almost the same hash functions. Read the docs on transient,
persistent!, conj!, etc. Transient data struc
For the most part, I *believe* I understand why immutable data
structures with transactions are important to manage concurrent
operations to shared data, but I often wonder why it matters in some
cases...
For example, what if I have a hash-map that needs to handle concurrent
changes to the data st