Implied DO

Implied DO-loops provide a fast way of listing many items. These items, depending on the place where an implied DO is used, can be variables, expressions, or even implied DO-loops.

Syntax and Semantics

The syntax of an implied DO is the following:
( item-1, item-2, ...., item-n, DO-var = initial, final, step )

( item-1, item-2, ...., item-n, DO-var = initial, final )
It starts with a (, followed by a set of items, separated by commas, followed by a DO variable, an equal sign, an initial value, a final value, and a step-size, end ends with a ). Like a typical DO-loop, if the step size is 1, it can be eliminated.

Depending on the place where an implied DO is used, the items can be variables, including array elements, or expressions.

The meaning of an implied DO is simple: For each possible value of the DO variable, all items (i.e., item-1, item-2, ..., item-n) are listed once and adjacent items are separated by commas.

Examples

Nested Implied DOs

An implied DO can be an item of another implied DO. For a nested implied DO, it would be better to work from outside-in and treat an inner implied DO as an item. The following examples illustrate this idea.