// when blog is done https://cookeylangblog.cookeylangteam.repl.co

loops

There are 6 types of loops.

While loop

var i = 0;
while (i < 10) {
  println (i);
  i ++;
}

It is similar to

var i = 0;
do {
  println (i);
  i ++;
} while (i < 10);

but the do { ... } while ( ... ); will always execute at least once.

For loop

for (var i = 0; i < 10; i ++) {
  println (i);
}

Do for

forrep (i, 0, 10, 1) {
  println (i);
}

A forrep () {} loop has special syntax:

forrep ([variableName], [startValue (inclusive)], [endValue (exclusive)], [incrementer]) {
  %% code
}

Overloads

forrep ([repetition amount]) {
  %% code
}
forrep ([variableName], [endValue (exclusive)], [incrementer]) {
  %% code
}

[VariableName] starts at 0.

forrep ([variableName], [startValue (inclusive)], [endValue (exclusive)], [incrementer]) {
  %% code
}

Foreach

Not done

var array = [1, 2, 3];
foreach (var item in array) {
  println (item);
}

The syntax,

foreach ([variable name] in [array])