Em Qua, 2009-05-20 às 19:55 -0500, John M. Dlugosz escreveu: > If you would be so kind, please take a look at > <http://www.dlugosz.com/Perl6/web/med-loop.html>. I spent a couple days > on this, and besides needing it checked for correctness, found a few > issues as well as more food for thought.
Some issues... * The way to get an iterator is to ask for .Iterator() (this is in S07) * It's not the capture itself that presents two different versions of being a list, but rather the assignment in itself that traverses the capture while flattening it. i.e.: my $x := map { $_ * 2 for 1,2,3 }, 1,2,3; say $x[0]; # (1,2,3) say $x[0;0]; # 1 say $x[1]; # (2,4,6) say $x[1;0]; # 2 as a contrast to my @x = map { $_ * 2 for 1,2,3 }, 1,2,3; say @x[0]; # 1; say @x[0;0]; # ERROR say @x[1]; # 1; say @x[1;0]; # ERROR So, the list assignment really looks like my $iterator = (map { $_ * 2 for 1,2,3 }, 1,2,3).Iterator(); my @x := Array.new; while ((my $it = $iterator.get) !=== Nil) { @x.push($it) } Where the map is consumes an iterator by itself, so you could expand it as... # this happens inside the &map function installed in CORE my $map_input = (1,2,3).Iterator(); my $map_output = $MapIteratorInternalType.new( :input($map_input), :code({ $_ * 2 for 1,2,3 }) ); # this happens in the assignment my $iterator = $map_output.Iterator(); my @x := Array.new; while ((my $it = $iterator.get) !=== Nil) { @x.push($it) } The text is fantastic... it's really awesome how you got into the guts of Perl 6 while still preserving brevity and clarity... daniel