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