Skip to content

Continue

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

Continue[] proceeds to the next iteration of the nearest enclosing Do, For, or While loop.

Continue[] skips the remainder of the current loop body.

Continue[] takes effect as soon as it is evaluated.

Notes Continue has attribute Protected.

Examples (2)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (2)

In[1]:= r = 0; Do[If[EvenQ[i], Continue[]]; r += i, {i, 10}]; r
Out[1]= 25

In[2]:= r = 0; For[i = 1, i <= 10, i++, If[EvenQ[i], Continue[]]; r += i]; r
Out[2]= 25

Implementation notes

  • Has attribute Protected.
  • Takes effect as soon as it is evaluated. In Do it advances the iterator and re-tests; in For it evaluates the increment step then re-tests; in While it re-evaluates the test.
  • Outside any loop, Continue[] emits the message Continue::nofwd and returns Hold[Continue[]].

Attributes: Protected.

References

See also: Do, For, While