On Jan 20, 4:44 pm, Jason Wolfe <jawo...@berkeley.edu> wrote:
> Apologies for multiple posts; I will try to thoroughly investigate
> things before starting posting next time. Anyway, to round out the
> thread, here are corresponding results for intersection and union:
Well, that didn't last too long ... from now on ... :) Anyway, there
was a bug in fast-intersection when s2 was not a set. Fixed version:
(defn fast-intersection "Like intersection, but faster." [s1 s2]
(cond (not (set? s2))
(reduce (fn [result item]
(if (contains? s1 item)
(conj result item)
result))
#{} s2)
(> (int (count s1)) (int (count s2)))
(fast-intersection- s1 s2)
:else
(fast-intersection- s2 s1)))
-Jason
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---