Newsgroups: perl.perl6.language
From: d...@lighthouse.tamucc.edu (Jonathan Scott Duff)
Date: Wed, 10 Dec 2003 23:02:16 -0600
Local: Thurs, Dec 11 2003 12:02 am
Subject: Re: Iterating through two arrays at once
On Wed, Dec 10, 2003 at 11:44:15PM -0500, Joe Gottman wrote: FWIW, I like the former even though the latter has lots of precedent > In Perl 6, how will it be possible to iterate through two arrays at the > same time? According to Apocalypse 4, the syntax is > for @a; @b -> $a; $b { > According to the book "Perl 6 Essentials" the syntax is > Which of these is right? (of course, this being Perl, both may be right). in other languages. > Whichever of these syntaxes is right, what happens when @a and @b are I believe that case 3) is the "right" answer. Why do you need to > of different sizes? I can think of three possible behaviors, each with > its potential drawbacks: > 1) The loop executes min(+ @a, + @b) times, then finishes > In cases 1) and 2), the problem is how to get the elements of the differentiate the undefs? If you cared about whether one array was bigger than the other, surely you could check that yourself. In any case, run-time properties (is this redundant?) can help you out. Perhaps you get an "undef but out_of_bounds" kind of value back when you run off the end of the shorter array. -Scott You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||