Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


evaluates expr n times.

evaluates expr with the variable i successively taking on the values 1 through imax (in steps of 1).

starts with i=imin.

uses steps di.

uses the successive values i1, i2, .

evaluates expr looping over different values of j etc. for each i.


  • Do uses the standard Wolfram Language iteration specification.
  • You can use Return, Break, Continue, and Throw inside Do.
  • Unless an explicit Return is used, the value returned by Do is Null.
  • Do[expr,Infinity] continues evaluating expr until explicitly told to exit through a function such as Break, Return, Throw, Abort, or Quit.
  • 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.
  • Do[expr,spec1,spec2] is effectively equivalent to Do[Do[expr,spec2],spec1].
Introduced in 1988
| Updated in 2015