Re: cells/add-watch question

2009-03-11 Thread Timothy Pratley
And equality time does depend on the size of the data structure too it seems: user=> (def v (doall (range 1000))) user=> (def v2 (doall (range 1000))) user=> (time (= v2 v)) "Elapsed time: 2.772923 msecs" user=> (def v (doall (range 10))) user=> (def v2 (doall (range 10))) user=> (time (=

Re: cells/add-watch question

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 6:57 pm, linh wrote: > i didn't think of that. > if equality tests is instant, would finding out the difference also be > instant? > for example, is this instant: (difference new-set old-set) ? I don't think so: (defn set-difference-time-test [n] (let [s1 (set (apply hash-map

Re: cells/add-watch question

2009-03-11 Thread linh
i didn't think of that. if equality tests is instant, would finding out the difference also be instant? for example, is this instant: (difference new-set old-set) ? On Mar 11, 11:11 pm, Timothy Pratley wrote: > > This is beacuse my-atom contains a lot > > of data and I don't want to search for t

Re: cells/add-watch question

2009-03-11 Thread Timothy Pratley
> This is beacuse my-atom contains a lot > of data and I don't want to search for the change. Just curious, but shouldn't equality tests in Clojure always be instant regardless of data size due to shared structure? I suppose I'm curious what 'shared structure' gives and what it doesn't. --~--~-

Re: cells/add-watch question

2009-03-11 Thread linh
Thanks Raffael, I'll try that On Mar 11, 6:42 pm, Raffael Cavallaro wrote: > On Mar 11, 1:24 pm, Raffael Cavallaro > wrote: > > > ;; this just makes a big map atom where integer keys are associated > > with integer values > > should rather be as follows to get integer keyword keys: > > (def my-

Re: cells/add-watch question

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 1:24 pm, Raffael Cavallaro wrote: > ;; this just makes a big map atom where integer keys are associated > with integer values should rather be as follows to get integer keyword keys: (def my-atom (atom (assoc (apply hash-map (take 1000

Re: cells/add-watch question

2009-03-11 Thread Raffael Cavallaro
On Mar 11, 11:20 am, linh wrote: > According to the API doc, add-watch must have 4 args: a key, a > reference, > its old-state and its new state. What I'm missing here is an addtional > arg that can be passed in some way to update-fn so that update-fn > knows what entries in my-atom has change