For

From Mesham
Revision as of 15:44, 15 April 2019 by Polas (talk | contribs) (6 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Syntax

for i from a to b
{
forbody
{

Semantics

The for loop can be thought of as syntactic sugar for a while loop, incrementing the variable after each pass and will loop from a to b

Example

#include <io>
#include <string>
function void main() {
   var i;
   for i from 0 to 9 {
      print(itostring(i)+"\n");
   };
};

This code example will loop from 0 to 9 (10 iterations) and display the value of i on each pass.

Since: Version 0.41b