On Tuesday 23 December 2008 14:44, Chris Bunch wrote: > I've got the newest version of Clojure and wrote a simple program to > generate a list of 100 random numbers, but I seem to get a lot of > duplicate numbers (especially when I pick a large upper bound for > rand-int). My code is pretty similar to an example in the Programming > Clojure book: > > (defn gen-rands [max-val] > (loop [result [] x 100] > (if (zero? x) > (sort result) > (recur (conj result (rand-int max-val)) (dec x)) > ) > ) > ) > > ... > > Is there anything I've done wrong that would result in me getting > 2147483647 so many times? Thanks in advance!
I don't know, but I'm always suspicious by that particular value and those of its ilk, to wit: 2147483647 = 0x7FFFFFFF (a.k.a. Integer/MAX_VALUE) Randall Schulz --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---