| |
perl.perl6.language |
No, S03 is probably just wrong there. Junctions are scalar values, and for =all(@foo) {...} to iterate the junction. : Is the whole block run once with 1,2 and 3, or does the I expect =all(@foo) would do the former, while all(@foo) would do : for all(1,2,3) { Well, { 2 => 1, 3 => 1 } is the more likely notation. : The "no coupling" in s03 suggests to me that the right I think =all(@foo) should do what you expect there. Without the = for any(1,2,3) {...} then it would have done the "next", because 1 < 2. I should say that I don't see that =all() is different from =any(). Larry
:
: 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?
don't flatten in list context. Maybe we need something like:
: junction go into the block and autothread each operation?
the latter, in which case you might as well have used "given" instead.
: next if $_ < 2; # testing 1 or all(1,2,3) ?
: %got{$_} = 1;
: }
: say %got.perl; # "(('2', 1), ('3', 1))" or "()" ?
: answer is "(('2', 1), ('3', 1))", but I'm just guessing.
it should return { 1 => 1, 2 => 1, 3 => 1 } since there's only one
loop iteration, and it is *not* true that all(1,2,3) < 2. If you'd
said
They each just produce a list in "random" order. Though I suppose,
if we say that =one(1,2,3) should randomly pick one value, then
=any(1,2,3) should pick anywhere from 1 to 3 values. And, of course,
=none(1,2,3) should return a list of all the things that aren't 1, 2,
or 3 in random order. Maybe a lazy implementation will be beneficial
at that point. :-)