List comprehensions: Difference between revisions
Content deleted Content added
J: attempt to clarify how this solution can be interpreted as a "list comprehension" |
→{{header|Perl 6}}: explain gather/take as lazy list primitive |
||
Line 489:
}</lang>
=={{header|Perl 6}}==
Perl 6 has single-dimensional list comprehensions that fall out naturally from nested modifiers; multidimensional comprehensions are also supported via the cross operator; however, Perl 6 does not (yet) support multi-dimensional list comprehensions with dependencies between the lists, so the most straightforward way is currently:
<lang perl6>my $n = 20;
gather for 1..$n -> $x {
Line 498:
}
}</lang>
Note that <tt>gather</tt>/<tt>take</tt> is the primitive in Perl 6 corresponding to generators or coroutines in other languages. It is not, however, tied to function call syntax in Perl 6. We can get away with that because lists are lazy, and the demand for more of the list is implicit; it does not need to be driven by function calls.
=={{header|PicoLisp}}==
|