The next Statement
next if condition
next name if condition
next integer if condition
When a simple next statement is executed, execution of the current iteration of the innermost repetition (for/while/do) statement is terminated and the next iteration, if any, begins.
Beginning the next iteration implies that the control variable is incremented, and then the tests for termination (as specified by the to-clause, while-clause, and/or until-clause if present) are applied before proceeding. Thus, an exit from the loop may occur as a result of next statement.
In effect, execution skips the remainder of the loop's body, and resumes just before the terminating end do or until clause of the repetition statement.
A multi-level next statement is a next followed by either the name of a for-loop control variable, or a positive integer.
If next is followed by the name of a variable, then execution continues with the next iteration of the innermost for-loop that has that variable as its control variable. Note that the variable is taken literally. It is not evaluated.
If next is followed by an integer N, then execution continues with the next iteration of the Nth innermost repetition statement. The statement next 1 is equivalent to just next.
A multi-level next in the two-variable form of for-in loop can refer to either of the two variables.
When a multi-level next is used within a loop expression, the referenced enclosing for must appear within the same expression. One cannot force the next iteration of an enclosing expression.
It is an error if a next is appears in a context other than within a repetition statement, or if a qualifed next appears there is no enclosing for-loop using the specified control variable or there are fewer than N enclosing repetition statements.
A next statement may optionally be followed by the keyword if and a condition to be evaluated. The next statement is executed if and only if the condition evaluates to true.
The statement next if condition is a convenient shorthand for, and semantically equivalent to, if condition then next; end if.
In Maple V Release 5.1 and earlier, next was just a Maple symbol. In Maple 6 and later, next is a keyword in the Maple language.
Print all the non-string entries in a list:
Print ordered pairs [1,1], [1,2], ..., [4,4], omitting any [i,j] where j > i.
Print the rows of a Matrix, skipping any rows containing a zero.
The multi-level and conditional next statements are new in Maple 2020.1
Download Help Document
What kind of issue would you like to report? (Optional)