develooper Front page | perl.perl6.language | Postings from April 2005

for all(@foo) {...}

Thread Next
From:
Brad Bowman
Date:
April 23, 2005 22:03
Subject:
for all(@foo) {...}
Message ID:
1114318936.4176.21.camel@oxum
Hi,

I'm trying to understand the following section in S03:

  S03/"Junctive operators"

  Junctions are specifically unordered.  So if you say
    for all(@foo) {...}
  it indicates to the compiler that there is no coupling between loop
  iterations and they can be run in any order or even in parallel.

Is this a "for" on a one element list, which happens to
be a junction, or does the all() flatten?

Is the whole block run once with 1,2 and 3, or does the 
junction go into the block and autothread each operation?

for all(1,2,3) {
   next if $_ < 2;  # testing 1 or all(1,2,3) ?
   %got{$_} = 1;
}
say %got.perl;      # "(('2', 1), ('3', 1))" or "()" ?

The "no coupling" in s03 suggests to me that the right
answer is "(('2', 1), ('3', 1))", but I'm just guessing.


Brad

-- 
  To ask when you already know is politeness. To ask when you don't know
  is the rule.                  -- Hagakure http://bereft.net/hagakure/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About