2009/3/26 Jon :
> 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 but my journey to
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 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 be something obvi
2009/3/25 David Plumpton :
> 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 Drive, Houghton-le-Spring,
On Mar 24, 12:43 pm, Paul Drummond 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/
;-)
--~--~-~--~~~---~--~~
You received
On Mar 23, 2009, at 10:36 PM, Paul Drummond wrote:
>
> 2009/3/24 Joshua Fox :
>>> 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
2009/3/24 Joshua Fox :
>> 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 I was
trying t
> 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 wrote:
>
> 2009/3/23 Krešimir Šojat :
> > (rand-int 49) will produce one in
2009/3/23 Krešimir Šojat :
> (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 was!
I did consid
> 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