While• While[test, body] evaluates test then body repetitively until test fails to give True. • 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. • See also: Do, For, Table.
Examples Using InstantCalculatorsHere are the InstantCalculators for the While function. Enter the parameters for your calculation and click Calculate to see the result.
Initialize the variable i before evaluating the While False Text Input.
Entering Commands DirectlyYou 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. The body of While must have an iteration command. The iteration in this example adds 2.
Clear the variable definition. The body of While can take more that just Print commands. Evaluate the cell to see the output.
Clear the variable definition.
|