Loops/For with a specified step: Difference between revisions
→{{header|Perl 6}}: Use a magic arithmetic series.
(adding MUMPS example) |
Underscore (talk | contribs) (→{{header|Perl 6}}: Use a magic arithmetic series.) |
||
Line 328:
=={{header|Perl 6}}==
{{works with|Rakudo|
With at least two values on the left-hand side, the series operator (<code>...</code>) can infer an arithmetic series. (With at least three values, it can infer a geometric series, too.)
<lang perl6>for 2 ... * + 2, 8 {▼
print "$_, ";
}
say 'whom do we appreciate?';</lang><!-- "Whom" is infinitely more amusing. -->
|