Operators > Programming Operators > The For Loop Operator
The For Loop Operator
Evaluates z for each value of the iteration variable x over the range y. Typically, at least one expression in the loop body, z, uses the value of x to change the calculation for each evaluation.
x is any valid variable name.
y is a value or sequence of values. Most frequently, y is a range variable, but you can also use a vector which results in a series of scalar values that x assumes in turn.
z is any valid expression or sequence of expressions. For example, a local assignment or a sequence of programming steps is allowed.
Watch this video to learn more about for loops:
Additional Information
You can type the word for and then press Ctrl+J to convert the word to a programming operator with all its placeholders.
Use a for loop when you know exactly how many times you want the body of the loop to execute.
You may want to exit a loop before its termination condition is met or to skip a particular iteration and proceed to the next one. You can control the execution of a loop by using the break and continue operators.
Was this helpful?