This is the most versatile loop construction, as it features:
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:
for
loop elements are separated by ','
instead of ';'
, and
Again, this choice is dictated by the pursue of simplicity.