Mathematica 9 is now available

Do

Usage

Do[expr,  imax ]expr赋值imax 次.
Do[expr,  i, imax ] 利用变量 i 以步长1递增至 imax expr赋值.
Do[expr,  i, imin, imax ]i = imin开始.Do[expr,  i, imin, imax, di ]使用步长 di.
Do[expr,  i, imin, imax ,  j, jmin, jmax , ... ] 对每一个 i 循环地根据不同的 j 等对expr赋值.


Notes

Do使用标准的 Mathematica迭代规范.
Do以一种非标准的方式对它的参数进行赋值(参见 A.4.2节).
• 你可以在Do的内部使用Return, Break, ContinueThrow.
• 如果没有使用一个明确的返回, Do的返回值为Null.
•参见Mathematica全书: 1.7.3节和 2.5.9节.
• 同时参见: For, While, Table, Nest, NestWhile, Fold.
Further Examples

Here is a simple Do loop to add the first 1000 integers.

In[1]:=  

In[2]:=  

In[3]:=  

Out[3]=

In[4]:=  

This loop creates a series of graphics that can be animated. Double-click on the graphic to start the animation, or select the cell brackets containing the graphics and choose Animate Selected Graphics in the Cell menu.

Evaluate the cell to see the graphic.

In[5]:=  



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.