Re: RFC: new clojure.set functions

2009-01-31 Thread Jason Wolfe
> 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

Re: RFC: new clojure.set functions

2009-01-31 Thread verec
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

RFC: new clojure.set functions

2009-01-29 Thread Jason Wolfe
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