> I'm must be missing something obvious for the [s1 s2] case of union:
>
> Is it only that you've measured (conj s1 s2) to be faster when s2 is
> the smallest ?
Yes, that's it. "conj" iterates through the second argument, and
since count is O(1) for sets, it makes sense to always iterate thro
I'm must be missing something obvious for the [s1 s2] case of union:
Is it only that you've measured (conj s1 s2) to be faster when s2 is
the smallest ?
(defn un
([s1 s2]
(reduce conj s1 s2))
... )
user=> (def a #{1 2 3})
user=> (def b #{4 5 6 7})
user
I've posted code for faster, multi-argument clojure.set functions
here:
http://paste.lisp.org/display/74534
Basic algorithms:
intersection: start with smallest set, and remove elements from it
that aren't in each other set
(always iterate through result-in-progress, which
w