- For evaluates its arguments in a nonstandard way.
- For[start,test,incr] does the loop with a null body.
- The sequence of evaluation is test, body, incr. For exits as soon as test fails.
- If Break is generated in the evaluation of body, the For loop exits.
- Continue exits the evaluation of body, and continues the loop by evaluating incr.
- Unless an explicit Return is used, the value returned by For is Null.
- Note that in an example like For[tot=0;i=0,i<3,i++,tot+=f[i]] the roles of the semicolon and comma are reversed relative to C-like programming languages.
Examplesopen allclose all
Introduced in 1988