5.5. for loops

This is the most versatile loop construction, as it features:

  1. a variable declaration and initialization (a Golo variable is always initialized anyway), and
  2. a loop progress condition, and
  3. a loop progress statement.

The following function shows a for loop:

function fact = |value, n| {
  var result = 1
  for (var i = 0, i < n, i = i + 1) {
    result = result * value
  }
  return result
}

As you can see, it is very much like a for loop in Java, except that:

Again, this choice is dictated by the pursue of simplicity.