Loops/Wrong ranges: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 194:
_stop = none;
_step = none;
_comment = none;
}
Line 246:
Range( -2, 2, 0 ) -> ./range.hgn:32:17: Invalid range.
Exit 3</pre>
=={{header|Kotlin}}==
Although Kotlin's 'for' statement can deal with a range of integers, the increment must be positive and so it cannot be used for this task. We therefore use instead a 'while' statement to generate the same sequence as a C language 'for' statement would (limited to a maximum of 10 elements as some sequences will be infinite) and wrap it in a function.
|