MOwa-Lang

Loops

Repeat blocks of code using the varaku in MowaLang.

Overview

In MowaLang, you can perform repeated actions using the varaku loop — similar to the for loop in other languages. It's helpful when you want to execute a block of code multiple times with a condition.

The loop follows a familiar structure: initialization, condition, and increment — all placed inside the varaku statement.

Syntax

varaku (initialization; condition; increment) {
  // loop body
}

example:

idhi i : number;

varaku (i = 0; i < 5; i++) {
  mowa i;
}

output:

01234

Loop Control Statements

MowaLang supports two control statements:

  • aagipo – exits the loop early (like break)
  • kaani – skips the current iteration and continues (like continue)

Example: Using aagipo

idhi i : number;

varaku (i = 0; i < 5; i++) {
  okavela (i == 3) ayithe {
    aagipo;
  }
  mowa i,"\n";
}

output:

0
1
2

Example: Using kaani

idhi i : number;

varaku (i = 0; i < 5; i++) {
  okavela (i == 3) ayithe {
    kaani;
  }
  mowa i,"\n";
}

output:

0
1
2
4

Nested Loops

MowaLang allows loops inside loops. This is useful for multi-level iterations, such as matrices or combinations.

idhi i : number;
idhi j : number;

varaku (i = 1; i <= 3; i++) {
  varaku (j = 1; j <= 2; j++) {
    mowa "i = ",i,", j = ",j;
    mowa "\n";
  }
}
i = 1, j = 1
i = 1, j = 2
i = 2, j = 1
i = 2, j = 2
i = 3, j = 1
i = 3, j = 2

Ready to take your code to the next level? Learn how to organize and reuse logic using Functions with the pani keyword.