Loops/For with a specified step: Difference between revisions
Gave more comprehensive examples including decrementing
(Gave more comprehensive examples including decrementing) |
|||
Line 2,043:
=={{header|Nim}}==
<syntaxhighlight lang="nim"
for n in 5 .. 9: # 5 to 9 (9-inclusive)
echo n
echo "" # spacer
for n in 5 ..< 9: # 5 to 9 (9-exclusive)
echo n
echo "" # spacer
for n in countup(0, 16, 4): # 0 to 16 step 4
echo n
echo "" # spacer
for n in countdown(16, 0, 4): # 16 to 0 step -4
echo n
</syntaxhighlight>
{{out}}
<pre>
5
6
9</pre>▼
7
8
9
5
6
7
8
0
4
8
12
16
16
12
8
4
0
=={{header|N/t/roff}}==
|