Difference between revisions of "For"

From Mesham
Jump to navigationJump to search
(Created page with '== 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 …')
 
m (6 revisions imported)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Syntax ==
 
== Syntax ==
  
for i from a to b forbody;
+
for i from a to b <br>
 +
{<br>
 +
forbody<br>
 +
{
  
 
== Semantics ==
 
== Semantics ==
Line 8: Line 11:
  
 
== Example ==
 
== Example ==
 
+
#include <io>
  var i;
+
#include <string>
for i from 0 to 9
+
  function void main() {
{
+
    var i;
    print[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.
 
This code example will loop from 0 to 9 (10 iterations) and display the value of ''i'' on each pass.
 +
 +
''Since: Version 0.41b''
 +
 +
[[Category:sequential]]

Latest revision as of 15:44, 15 April 2019

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