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 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

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

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

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 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/ ;-)

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

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

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

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

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 paul.drumm...@iode.co.ukwrote: 2009/3/23 Krešimir Šojat kso...@gmail.com:

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

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

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 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.

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