|
Repeat, Until |
Top Previous Next |
|
The Repeat statement causes one to execute a block of statements over and over until a logical condition is satisfied. The syntax of the Repeat statement is: repeat ( statements to be executed; until logical condition is true ); Examples: A binary root finder using Repeat may be found in repeat.gms repeat ( root=root+inc; function_value2= a-b*root+c*sqr(root); If((sign(function_value1) ne sign(function_value2) and abs(function_value1) gt 0 and abs(function_value2) gt tolerance), maxroot=root; signswitch=1 else If(abs(function_value2) gt tolerance, function_value1=function_value2; minroot=root;)); until (signswitch>0 or root > maxroot) ;); Notes:
|