I thought for sure it would be faster to use "some" to determine whether an item was in a list rather than convert the list to a set and then use "contains?", but it turns out I was wrong. The latter approach takes about 1/3 to 1/2 the time! This is the case even when the list contains 100 items. Of course I realize that if this is a commonly needed operation for a particular collection, it's better to use a set instead of a list in the first place.
(def stooges (list "Moe" "Larry" "Curly")) (time (some #(= % "Curly") stooges)) (time (contains? (set stooges) "Curly")) -- R. Mark Volkmann Object Computing, Inc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---