Hmm, none of the #Clojure collections quite fit what I need without doing something really slow to them :(
@GraemeF I would've thought rand-nth would do, but clearly you have a more interesting use case?
-
-
@darachennis I think this is O(n/2) on average (in case you didn't see already): (defn rand-from-set [m] (nth (seq m) (rand-int (count m)))) -
@GraemeF "java.lang.UnsupportedOperationException: nth not supported on this type: PersistentTreeSet" // Oh, how rude! ... :/ - 3 more replies
New conversation -
-
-
@darachennis rand-nth doesn't work on a set :(Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.