I would have worried that if dim and max were close you'd get to the last number and keep calling #(rand-int) and never hit the last number.
how does distinct work that it keeps that situation from occuring? On Aug 25, 12:26 pm, Christophe Grand <christo...@cgrand.net> wrote: > no, distinct uses a hash-set (nearly-constant lookup) so distinct is O(n). > > On Tue, Aug 25, 2009 at 6:19 PM, sebastien <sebastien....@gmail.com> wrote: > > > > The simplest I can think of is: > > > (defn make-random-numbers [dim max] > > > (take dim (distinct (repeatedly #(rand-int max))))) > > > But distinct itself gives order of growth O(n!), through it scans > > resulting list for every generated number, isn't it? > > -- > Professional:http://cgrand.net/(fr) > On Clojure:http://clj-me.blogspot.com/(en) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---