![]() The WhileLoop cannot have any statements between the ASSERT statement for the pre-conditions and the do statement of the loop, or between the loop statement and the ASSERT statement for the post-conditions ![]() ![]() In addition, the procedure must satisfy the following: WhileLoopProcedure ::= proc x 1, …, x m local v 1, …, v n, y 1, …, y p # Initialization statements y 1 ≔ f 1 ( x ) y 2 ≔ f 2 ( x, y 1 ) ⋮ y p ≔ f p ( x, y 1, …, y p − 1 ) ASSERT precondition while guard condition do if branch condition 1 then v 1 ≔ g 1 v, x, y ⋯ v n ≔ g n v, x, y elif branch condition 2 then ⋯ else ⋯ end if end do ASSERT postcondition return h x, v, y end proc WhileLoop s can be generated from procedure s that have the following form: The inner lists have two elements: the conditional expression for the branch of the if statement and a list of equations representing the branch's statement sequence. Each inner list consists of four elements: the loop variable name, the lower bound, the step size and the upper bound.īody : listlist, one entry for each if branch in the loop's body. Layers : listlist, one for each layer of for loop in p. Initialization : list of equation s representing the assignments that occur before the loop Parameters : list of the parameters passed to the procedure p that are not in arrays Variables : list of the loop's index variables, one per layer of nested for loopsĪrrays : list of indexable variables being read from or written to in the loop This data structure is a Record with the following fields: This command processes such procedures and returns a ForLoop data structure. Optionally, the lower/upper bounds may have the ceil / floor function applied, respectively. The loops' lower bounds lb i / upper bounds ub i must be linear in the loops' index variables v, parameters p and local variables x, or the max / min of a sequence of such expressions, respectively. The indices of the loop's arrays must be polynomials with rational coefficients The assignments in the loop body must assign to indexable variables In addition, the loop must have the following properties: IfStatement ::= if c 1 then AssignmentStatements elif c 2 then AssignmentStatements ⋮ else AssignmentStatements end ifĪssignmentStatements ::= p j ≔ g j p, v, x + LoopBody ::= ForLoop &verbar IfStatement &verbar AssignmentStatements More precisely, they can be defined as follows, where ::= means "defined as", &verbar means "or", and … + means one or more of the enclosed:įorLoopProcedure ::= proc p 1, …, p m local v 1, …, v n, x 1, …, x p # Initialization statements x 1 ≔ f 1 ( p ) x 2 ≔ f 2 ( p, x 1 ) ⋮ x p ≔ f p ( p, x 1, …, x p − 1 ) ForLoop end procįorLoop ::= for v i from lb i to ub i LoopBody end do They consist of initialization statements, followed by a (possibly nested) for loop. The procedures that can be converted to ForLoop s have a particular structure. A while loop is a loop that recursively updates its loop variable(s) until its guard condition (while clause) is no longer satisfied. In this package, a for loop is understood to be a loop that iterates over some index variable(s), reading from and updating the entries of an indexable variable, i.e. Both for loops and while loops are represented in Maple using do statements. This command processes the procedure p and returns either a ForLoop or a WhileLoop data structure, depending on p 's form. Create a WhileLoop or ForLoop from a Maple procedure
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |