3.9 Proving the Predicate before Looping

This technique relies on a set, e.g. GETTRUTH, with two members, e.g. PROVE_IT and DO_THE_WORK. An outer loop over this set is placed before the desired loop. When the loop variable takes the value PROVE_IT, the predicate is proved immediately; with the other value the desired loop is executed. This is shown in the example below, which applies the technique to the example from section 3.6.

IF      ?PASS IN GETTRUTH
AND     ( ?PASS EQ "PROVE_IT"
           OR ?ITEM IN SET
                  AND <intermediate code>
                  AND ( <test' on ?ITEM>
                         OR <further code for successful ?ITEM>
                            AND BREAK ?ITEM
                       ) 
         )
THEN    < predicate >


Back                                Next
Comments