On Mar 11, 6:57 pm, linh <nguyenlinh.m...@gmail.com> 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
                       (take n
                             (interleave
                              (map #(keyword (str %))
                                   (iterate inc 0))
                              (iterate inc 100)))))
        s2 (conj s1 [:foozle "woozle"])]
    (time (difference s2 s1))))

user=> (set-difference-time-test 1000)
"Elapsed time: 1.58 msecs"
#{[:foozle "woozle"]}
user=> (set-difference-time-test 10000)
"Elapsed time: 35.435 msecs"
#{[:foozle "woozle"]}
user=> (set-difference-time-test 100000)
"Elapsed time: 147.856 msecs"
#{[:foozle "woozle"]}
user=> (set-difference-time-test 1000000)
"Elapsed time: 1061.1 msecs"
#{[:foozle "woozle"]}
--~--~---------~--~----~------------~-------~--~----~
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
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