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)) ) ) ) And when I run it: user=> (gen-rands 9e9) (43062994 87944108 135195337 273355200 338785553 418221294 435319656 859624282 926596339 984111494 1126155049 1168060016 1302127601 1332630645 1415397492 1428195873 1432995126 1502674948 1509275367 1718744051 1802984623 1830741631 1835582186 1863727340 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647) Is there anything I've done wrong that would result in me getting 2147483647 so many times? Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---