Re: the x operator

2004-09-17 Thread Randal L. Schwartz
> "Sid" == Sid <[EMAIL PROTECTED]> writes: Sid> To get $n random numbers into @list, use: Sid> @list = (rand(4)) x $n; You mean, to get the same random number $n times into a list, correct? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> h

Re: the x operator

2004-09-17 Thread Jenda Krynicky
From: Sid <[EMAIL PROTECTED]> > To get $n random numbers into @list, use: > > @list = (rand(4)) x $n; > > ~Sid Nope. This way you get $n times the same random number. Try: print join(', ', (rand(4)) x 5); You need to do something like this: @list = map rand(4), (1..$n); or

Re: the x operator

2004-09-17 Thread Sid
To get $n random numbers into @list, use: @list = (rand(4)) x $n; ~Sid On Fri, 17 Sep 2004 15:02:55 +0200 (CEST), c r <[EMAIL PROTECTED]> wrote: > Hi! > > Is it possible to avoid another loop by using the x operator? I.e. > > push(@list, rand(4)); > > gives me one

Re: the x operator

2004-09-17 Thread Sid
To get $n random numbers into @list, use: @list = (rand(4)) x $n; ~Sid On Fri, 17 Sep 2004 15:02:55 +0200 (CEST), c r <[EMAIL PROTECTED]> wrote: > Hi! > > Is it possible to avoid another loop by using the x operator? I.e. > > push(@list, rand(4)); > > gives me one

the x operator

2004-09-17 Thread c r
Hi! Is it possible to avoid another loop by using the x operator? I.e. push(@list, rand(4)); gives me one element in @list. Can I somehow use the x operator to produce two different elements in the @list?