Of course. But, to counter-nitpick, the OP asked for "the first N *unique* random floats". Hence distinct.
I might point out, though, that getting floats and truncating them to two digits is wasting a lot of the processor's time, and yours in writing it. I'd get integers first and then divide to turn them into floats: (map #(str (/ % 100.0)) (take 100 (distinct (repeatedly #(rand-int 10000))))) ("36.35" "92.07" "41.02" "61.19" "12.19" "54.07" "11.39" "41.55" "25.87" "20.84" "88.42" "74.26" "24.87" "75.45" "60.82" "1.06" "68.24" "54.36" "89.64" "63.99" "94.73" "79.75" "40.96" "90.57" "79.56" "59.18" "65.45" "24.18" "49.95" "13.15" "5.88" "38.99" "14.98" "93.17" "38.41" "82.29" "53.7" "82.61" "30.39" "67.77" "96.84" "30.41" "28.42" "3.63" "32.23" "53.97" "73.96" "76.15" "61.65" "61.51" "80.41" "25.73" "37.77" "86.59" "95.9" "45.85" "13.95" "97.85" "18.63" "7.59" "46.51" "45.56" "28.37" "62.39" "99.77" "33.22" "46.36" "3.77" "17.05" "57.38" "38.95" "75.52" "37.72" "41.4" "35.4" "97.82" "59.82" "0.38" "39.27" "45.74" "70.51" "13.24" "74.38" "55.07" "92.69" "45.54" "21.53" "49.42" "24.82" "61.68" "70.05" "79.37" "83.37" "89.07" "29.4" "39.66" "92.49" "48.23" "20.7" "83.6") On Feb 18, 4:19 pm, Joost <jo...@zeekat.nl> wrote: > On Feb 19, 12:38 am, Alan <a...@malloys.org> wrote: > > > user=> (take 100 (distinct (repeatedly #(rand-int 200)))) > > Nitpick: the distinct call may be useful in some circumstances, but if > you want a truly random sequence, you definitely do not want it there. > > Joost. -- 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