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

for all(@foo) {...}

Thread Next
Brad Bowman
April 23, 2005 22:03
for all(@foo) {...}
Message ID:

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.


  To ask when you already know is politeness. To ask when you don't know
  is the rule.                  -- Hagakure

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About