I have this bit of code. The first, not nested, mapdisplays some things, but the nested does not. I think I understand why the second does not work. The result is a lazy sequence, and Perl 6 collects the results. It's great. But not the first (not nested) maplazy in the same way? How does it output anything if I do nothing with the result of the map? That is, how is the first lazy? Does the receiver context automatically get where I have to explicitly point sink(or something) to the nested one? Anyway, I think Perl 6 will be able to figure this out for me.
my @array = (1, 2), (3, 4), ('a', 'b');
say "---On its own:";
my @item = 1, 2, 3;
@item.map: {
say $_;
};
say "---Inside another map:";
@array.map: {
my @item = 1, 2, 3;
@item.map: {
say $_;
}
};
Here's the conclusion:
1
2
3
"map" "" Perl 6?. , , , .
eager, sink map:
say "---eager:";
@array.map: {
my @item = 1, 2, 3;
eager @item.map: {
say $_;
}
};
say "---sink:";
@array.map: {
my @item = 1, 2, 3;
sink @item.map: {
say $_;
}
};
say "---assignment:";
@array.map: {
my @item = 1, 2, 3;
@ = @item.map: {
say $_;
}
};