You probably figured this out, but what you want is something like:
(map rand-int (repeat SIZE MAX))
On Mar 23, 7:43 pm, Paul Drummond paul.drumm...@iode.co.uk wrote:
Hi all,
user= (repeat 10 (rand-int 49))
(4 4 4 4 4 4 4 4 4 4)
Can someone please tell me why this doesn't work?
It must
2009/3/26 Jon jon.na...@gmail.com:
You probably figured this out, but what you want is something like:
(map rand-int (repeat SIZE MAX))
In fact - I didn't think of this - thanks! This is what I used:
(map rand-int (repeat Integer/MAX_VALUE))
I have been around since the beginning of Clojure
On Mar 24, 12:43 pm, Paul Drummond paul.drumm...@iode.co.uk wrote:
Hi all,
user= (repeat 10 (rand-int 49))
(4 4 4 4 4 4 4 4 4 4)
Can someone please tell me why this doesn't work?
I think this explains your problem:
http://xkcd.com/221/
;-)
2009/3/25 David Plumpton david.plump...@gmail.com:
I think this explains your problem:
http://xkcd.com/221/
There is something to be said for that function. At least it has no
side-effects ;)
--
Iode Software Ltd, registered in England No. 6299803.
Registered Office Address: 12 Sancroft
2009/3/23 Krešimir Šojat kso...@gmail.com:
(rand-int 49) will produce one integer, and repeat will repeat it 10
times, that is why you see same number repeated.
How embarrassing!
As soon as I switched my machine off last night I realised rand-int
was only being called once - of course it
Why presumably with side effects?Otherwise you would use repeat. A pure
function returns the same value every time, so there is no reason to call
it repeatedly.
Joshua
On Tue, Mar 24, 2009 at 10:04 AM, Paul Drummond paul.drumm...@iode.co.ukwrote:
2009/3/23 Krešimir Šojat kso...@gmail.com:
2009/3/24 Joshua Fox joshuat...@gmail.com:
Why presumably with side effects?
Otherwise you would use repeat. A pure function returns the same value
every time, so there is no reason to call it repeatedly.
Yup, that makes sense.
Random numbers are side-effecting (is that the right term?) and
On Mar 23, 2009, at 10:36 PM, Paul Drummond wrote:
2009/3/24 Joshua Fox joshuat...@gmail.com:
Why presumably with side effects?
Otherwise you would use repeat. A pure function returns the same
value
every time, so there is no reason to call it repeatedly.
Yup, that makes sense.
user= (repeat 10 (rand-int 49))
(4 4 4 4 4 4 4 4 4 4)
Hi,
(rand-int 49) will produce one integer, and repeat will repeat it 10
times, that is why you see same number repeated.
To fix this use:
user= (take 10 (repeatedly #(rand-int 49)))
(21 29 9 20 15 34 8 28 16 26)
--
Krešimir Šojat
Hi all,
user= (repeat 10 (rand-int 49))
(4 4 4 4 4 4 4 4 4 4)
Can someone please tell me why this doesn't work?
It must be something obvious but I can't see the wood for the trees
right now - it's late and my head hurts!
Thanks,
Paul.
--
Iode Software Ltd, registered in England No. 6299803.
10 matches
Mail list logo