Once you notice that you usually need a fast solution. The easiest solution 
is to just pass around an instance of java.util.Random which you create 
with the desired seed. Another options is to have a constructor function 
returning a "rand" function.

(defn prng [seed]
  (let [rnd (java.util.Random. (long seed))]
    (fn rand [] (.nextDouble rnd))))

You can specify different arities as you need them. But obviously this is 
more limited than just passing around the Random object since you can't 
choose between the next* methods.

But having a built-in rebindable (thread-local) "rand" is preferable in the 
long run.

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to