Loops/With multiple ranges: Difference between revisions

Content added Content deleted
(Added Algol W)
m (→‎{{header|Perl 6}}: a little exposition)
Line 396:
=={{header|Perl 6}}==
 
This task is really conflating things, (at least in Perl 6). Sequences and loops are two different concepts and may be considered / implemented separately from each other.
Also displaying the j sequence since it isn't very large.
 
Yes, you can generate a sequence with a loop, and a loop can use a sequence for an iteration value, but the two are somewhat orthogonal and don't necessarily overlap.
 
Sequences are first class objects in Perl 6. You can (and typically do) generate a sequence using the (appropriately enough) sequence operator and can assign it to a variable and/or pass it as a parameter; the entire sequence, not just it's individual values. It ''may'' be used in a looping construct, but it is not necessary to do so.
 
Various looping constructs often do use sequences as their iterator but not exclusively, possibly not even in the majority.
 
 
Also displayingDisplaying the j sequence as well since it isn't very large.
 
<lang perl6>sub comma { ($^i < 0 ?? '-' !! '') ~ $i.abs.flip.comb(3).join(',').flip }