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 t
On Feb 19, 12:38 am, Alan 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 subscri
Thanks, Alan and Daniel. That is exactly what I was looking for.
On Feb 18, 6:53 pm, Daniel Solano Gomez wrote:
> On Fri Feb 18 15:38 2011, Alan wrote:
>
> > user=> (take 100 (distinct (repeatedly #(rand-int 200
> > (100 55 65 188 90 150 144 72 137 74 187 158 163 28 140 146 111 116 135
> > 88
On Fri Feb 18 15:38 2011, Alan wrote:
> user=> (take 100 (distinct (repeatedly #(rand-int 200
> (100 55 65 188 90 150 144 72 137 74 187 158 163 28 140 146 111 116 135
> 88 29 81 36 173 149 79 16 105 82 162 60 20 49 50 91 176 165 3 56 22 9
> 85 44 101 33 134 186 128 141 103 92 143 123 23 129 83
user=> (take 100 (distinct (repeatedly #(rand-int 200
(100 55 65 188 90 150 144 72 137 74 187 158 163 28 140 146 111 116 135
88 29 81 36 173 149 79 16 105 82 162 60 20 49 50 91 176 165 3 56 22 9
85 44 101 33 134 186 128 141 103 92 143 123 23 129 83 80 5 172 179 166
167 66 195 99 164 38 138 148
I want to get first N (for example 100) unique random floats. Here is
what I have.
(defn rand-flt [max-flt]
(format "%.2f" (rand max-flt)))
(defn gen-rand-flts [max-flt]
(lazy-seq (cons (rand-flt max-flt) (gen-rand-flts max-flt
(defn get-n-floats [max-float, how-many]
(let [tf-fun (f
I want to get first N (for example 100) unique random floats. Here is
what I have.
(defn rand-flt [max-flt]
(format "%.2f" (rand max-flt)))
(defn gen-rand-flts [max-flt]
(lazy-seq (cons (rand-flt max-flt) (gen-rand-flts max-flt
(defn get-n-floats [max-float, how-many]
(let [tf-fun (f