Legacy Documentation

Mathematica® Teacher's Edition (2002)

This is documentation for an obsolete product.
Current products and services
 Documentation /  Mathematica Teacher's Edition /  Built-in Functions /  Programming /  Flow Control /

While

FilledSmallSquare While[test, body] evaluates test, then body, repetitively, until test first fails to give True.

FilledSmallSquare While[test] does the loop with a null body.
FilledSmallSquare If Break[ ] is generated in the evaluation of body, the While loop exits.
FilledSmallSquare Continue[ ] exits the evaluation of body, and continues the loop.
FilledSmallSquare Unless Return[ ] is generated, the final value returned by While is Null.
FilledSmallSquare Example: i=0; While[i < 0, tot = tot + f[i]; i++]. Note that the roles of ; and , are reversed relative to the C programming language.
FilledSmallSquare See The Mathematica Book on the web: Section 2.5.9.
FilledSmallSquare See also: Do, For, NestWhile, Nest, Fold, Select.