For Loops

For loops in Gwion is pretty similar to classic C syntax

basic loops

for(var int i; i < 3; ++i)
   <<< i >>>;

It also works with a block of code.

for(var int i; i < 3; ++i) {
   i/2 => var float f1;
   i/2. => var float f2;
   <<< i, " " , f1, " ", f2 >>>;
}

Nested Loops

var int array[3][4];

for(var int i; i < 3; ++i) {
  for(var int j; j < 4; ++j) {
    <<< array[i][j] >>>;
  }
}

Auto Loops

Simple auto loop

var int array[2][3];
foreach(a: array) {
  <<< a >>>;
  foreach(b: a)
    <<< b >>>;
}

Auto Pointer loop

If you want to change it the value in the array, you need a pointer

var int array[2][3];
var int i;
foreach(a: array) {
  foreach(b: a)
    <<< ++i => b >>>;
}
foreach(a: array) {
  foreach(b: a)
    <<< b >>>;
}
built with mdBook
You'll find the source here, Luke!