Legacy Documentation

Mathematica CalcCenter 2 (2002)

This is documentation for an obsolete product.
Current products and services

Documentation / CalculationCenter / Functions / Defining Functions / Iterators /

While

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

FilledSmallSquare Example: i = 0; While[i < 0, tot += f[i]; i++]. Note that the roles of ; and , are reversed relative to the C programming language.

FilledSmallSquare See also: Do, For, Table.

Examples

Using InstantCalculators

Here are the InstantCalculators for the While function. Enter the parameters for your calculation and click Calculate to see the result.

In[1]:=

Initialize the variable i before evaluating the While False Text Input.

In[2]:=

In[3]:=

Entering Commands Directly

You can paste a template for this command via the Text Input button on the While Function Controller.

The iteration variable, i, must first be initialized.

In[4]:=

The body of While must have an iteration command. The iteration in this example adds 2.

In[5]:=

Clear the variable definition.

In[6]:=

The body of While can take more that just Print commands. Evaluate the cell to see the output.

In[7]:=

Clear the variable definition.

In[8]:=



ja