On Tue, Aug 25, 2009 at 4:16 PM, sebastien <[email protected]> wrote:

>
> What is the most efficient way to generate list of unique random
> numbers? The function must look something like this:
>
> (defn make-random-numbers [dim max]
>   ....)


The simplest I can think of is:
(defn make-random-numbers [dim max]
  (take dim (distinct (repeatedly #(rand-int max)))))

Christophe

-- 
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 [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to