On Dec 23, 3:10 pm, Jason <jawo...@berkeley.edu> wrote:
> For the time-being, you could try something like:
>
> user> (def *random* (java.util.Random.))
> #'user/*random*
>
> user> (defn my-rand-int [max-val]
>         (let [bit-length (.bitLength (BigInteger. (str max-val)))]
>           (loop []
>             (let [x (BigInteger. bit-length *random*)]
>               (if (< x max-val)
>                   x
>                 (recur))))))
> #'user/my-rand-int

BigInteger has a constructor that takes a byte[] array, so you could
just give it an array of randomly generated bytes.  I'll work on some
code to do that.

mfh
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to