6.5.1 OPERATIONAL CONSTRUCTS
All third generation languages have explicit loop constructs. These are implemented as Do-While, Repeat-Until, For, and others. The loop construct can be recreated with a production as illustrated in Figure 78. The two productions in this example allow the numbers 1 through 10 to be sequentially printed. The first production, with Hypothesis Initialize, is an initialization production. When condition Go is made true, the hypothesis becomes true and the subsequent actions are taken. In the actions, variable Counter is set to zero and the hypothesis Loop is invoked.
The second production in Figure 78 is self-referential. Hypothesis Loop is set for evaluation, with the condition that Counter is less than or equal to 10 being true. Loop is set to true and the actions occur. The value of Counter is printed and incremented by one. Then the value of the Loop hypothesis is reset to unknown and the same Loop hypothesis is called for re-evaluation.
While the Counter value remains less than or equal to 10, the printing of the counter value will continue. Once the Counter value exceeds 10, making the condition of the rule evaluate to false, the Loop hypothesis is set to false and no further action is taken.
Figure 78 Iteration with Productions