> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 21, 2001 5:50 AM
> To: Sterin, Ilya; 'raptor '; Perl 6 Language
> Subject: RE: array/hash manipulation [was :what's with 'with'?]
>
>
> "Sterin, Ilya" <[EMAIL PROTECTED]> wrote:
> > Just one question, how
> > would merge behave on two different sized arrays.
> >
> > @a = (1..5);
> > @b = (1..10);
> > merge(@a, @b);
> >
> > ##Would return (1,1,2,2,3,3,4,4,5,5,??????????
> >
> > Would it stop on the shortest array.  Couldn't quite find such
> explanation
> > in the RFC.
> >
> I don't think I specified this in the RFC, since I remember having some
> debates with Damian and others about it that weren't resolved. Now that
> I've had a chance to think about this some more, I think the correct
> behaviour is for the shorter list to reset to the start and continue.

That would be one possible way, but when comparing two array of different
lengths, I guess I would expect undef to compare to the elements of the
longest array that bypassed the length of the shortest array, but that
wouldn't be a problem, just extra code to undef all elements of the shortes
array to equal the length of the longest array.

$shor_arr[$_] = undef for (($#long_arr - $#shor_arr)..$#long_arr);

But now I am trying to figure out, if you are not comparing elements of the
array and for example if you need to loop through 3 arrays at the same time,
but you need to know, whithin the loop, when the shortest array's last
element is reached, how would that be accomplished within the loop if the
array would just be reset and continue until the longest end is reached?


Ilya


>It
> is this behaviour that is the source of J and APL's broadcasting
> flexibility. For details see:
>   http://www.jsoftware.com/primer/agreement.htm
>
> --
>   Jeremy Howard
>   [EMAIL PROTECTED]

Reply via email to