Re: Trying to get a list of random numbers using repeat

2009-03-26 Thread Paul Drummond
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

Re: Trying to get a list of random numbers using repeat

2009-03-26 Thread Jon
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

Re: Trying to get a list of random numbers using repeat

2009-03-25 Thread Paul Drummond
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,

Re: Trying to get a list of random numbers using repeat

2009-03-25 Thread David Plumpton
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

Re: Trying to get a list of random numbers using repeat

2009-03-24 Thread David Sletten
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

Re: Trying to get a list of random numbers using repeat

2009-03-24 Thread Paul Drummond
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

Re: Trying to get a list of random numbers using repeat

2009-03-24 Thread 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. 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

Re: Trying to get a list of random numbers using repeat

2009-03-24 Thread Paul Drummond
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

Re: Trying to get a list of random numbers using repeat

2009-03-23 Thread Krešimir Šojat
> 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 --~-

Trying to get a list of random numbers using repeat

2009-03-23 Thread Paul Drummond
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.