This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)


Updated In 6 Graphic
Do[expr, {imax}]
evaluates expr imax times.
Do[expr, {i, imax}]
evaluates expr with the variable i successively taking on the values 1 through imax (in steps of 1).
Do[expr, {i, imin, imax}]
starts with i=imin.
Do[expr, {i, imin, imax, di}]
uses steps di.
Do[expr, {i, {i1, i2, ...}}]
uses the successive values i1, i2, ....
Do[expr, {i, imin, imax}, {j, jmin, jmax}, ...]
evaluates expr looping over different values of j, etc. for each i.
  • Do uses the standard Mathematica iteration specification.
  • Unless an explicit Return is used, the value returned by Do is Null.
  • Do[expr, spec] first evaluates spec, then localizes the variable specified, and successively assigns values to it, each time evaluating expr.
  • Do effectively uses Block to localize values or variables.
  • In Do[expr, spec1, spec2] is effectively equivalent to Do[Do[expr, spec2], spec1].
New in 1 | Last modified in 6