On Sep 26, 6:04 pm, Benny Tsai <benny.t...@gmail.com> wrote: > The reason that (rand-nth (seq (sorted-set 1 2 3))) performs badly on large > sets is probably because nth is O(n) on sequences. nth is much much faster > on vectors, so I would suggest trying out (rand-nth (vec (sorted-set 1 2 > 3))) and see if that works for your application.
This will replace an O(n) call to "nth" with an O(n) call to copy into a vector, so still leaving me with O(n). -- 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 Note that posts from new members are moderated - please be patient with your first post. 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