Loops/For with a specified step: Difference between revisions

Content added Content deleted
(added Julia example)
(→‎{{header|Ada}}: Added incorrect template)
Line 2: Line 2:
Demonstrate a for loop where the step value is greater than one.
Demonstrate a for loop where the step value is greater than one.
=={{header|Ada}}==
=={{header|Ada}}==
{{incorrect|Ada|Ada does not allow integer literals in an enumeration type, only identifiers and character literals.}}
The FOR loop construct in Ada does not give the programmer the ability to directly modify the loop control variable during the execution of the loop. Instead, Ada automatically takes care of the modification of the loop control variable by incrementing it or decrementing it to be the next value in a specified discrete sequence. For this reason, in a "real" program, an Ada programmer would use a WHILE loop, or more likely a general LOOP, construct to perform this particular task. For the sake of this task, however, the following code demonstrates a way the task could be performed, when the range of loop control values is sufficiently small, through the definition of an enumeration type.
The FOR loop construct in Ada does not give the programmer the ability to directly modify the loop control variable during the execution of the loop. Instead, Ada automatically takes care of the modification of the loop control variable by incrementing it or decrementing it to be the next value in a specified discrete sequence. For this reason, in a "real" program, an Ada programmer would use a WHILE loop, or more likely a general LOOP, construct to perform this particular task. For the sake of this task, however, the following code demonstrates a way the task could be performed, when the range of loop control values is sufficiently small, through the definition of an enumeration type.