Legacy Documentation

Mathematica CalcCenter 2 (2002)

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

Documentation / CalculationCenter / Functions / Defining Functions / Iterators /

For

FilledSmallSquare For[start, test, incr, body] executes start, then repeatedly evaluates body and incr until test fails to give True.

FilledSmallSquare The sequence of evaluation is test, body, incr. The For exits as soon as test fails.

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

FilledSmallSquare See also: Do, Table, While.

Examples

Using InstantCalculators

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

In[1]:=

In[2]:=

In[3]:=

Entering Commands Directly

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

Here is a common form of a For loop. The semicolon separates the multiple commands of the start and the body. The loop terminates as soon as the test < 10 fails.

In[4]:=

Clear the variable definitions.

In[5]:=



ja