Loops/Wrong ranges: Difference between revisions
→{{header|Arturo}}: updated as invalid increments are now corrected or ignored (no error)
(New post.) |
SimonVerdi (talk | contribs) (→{{header|Arturo}}: updated as invalid increments are now corrected or ignored (no error)) |
||
Line 262:
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">
print "start stop increment"
loop @[
2
2
2
2
0
print [
pad ~"|start|" 2 pad ~"|stop|" 7 pad ~"|increment|" 7
pad "->" 9 try? -> @range.step: increment start stop
else -> "Error"▼
▲ else -> "Error"
]
</syntaxhighlight>
{{out}}
<pre>start stop increment
-2 2 1 -> [-2 -1 0 1 2]
-2 2 0 ->
-2 2 -1 -> [-2 -1 0 1 2]
-2 2 10 -> [-2]
2 -2 1 -> [2 1 0 -1 -2]
2 2 1 -> [2]
2 2 -1 -> [2]
2 2 0 ->
0 0 0 ->
=={{header|AWK}}==
|