harp:~ > cat a.rb
n, max, min = 42, 10, 6
p Array.new(n).map{ rand((max - min) + 1) + min}
harp:~ > ruby a.rb
[6, 8, 8, 10, 9, 7, 6, 8, 9, 7, 10, 10, 7, 7, 9, 9, 6, 9, 10, 6, 8, 10, 6, 9, 7, 8, 8, 10, 8, 9, 9, 9, 10, 7, 9, 6, 6, 8, 8, 10, 9, 7]
-a
···
On Wed, 15 Nov 2006, Josselin wrote:
I try to generate an array of N random numbers in range between 2 integers min and max
but I don't understand very well how to coordinate the sue of srand and rand..
is there an already written function for that ? and btw is there any place to find such useful functions ?
thanks
joss
--
y religion is very simple. my religion is kindness. -- the dalai lama