Mathematica 9 is now available

While

Usage

While[test, body] 重复计算test然后是body,直到test第一次不能给出True


Notes

While[test] 在一个空体中循环。
• 如果在计算body产生Break[ ],退出While循环。
Continue[ ] 退出body的计算,继续循环。
• 除非产生Return[ ]Throw[ ],由While返回的最后结果是Null
• 例如: i=0; While[i < 0, tot += f[i]; i++]. 注意 ;, 的作用与在 C 程序语言中是相反的.
• 参见Mathematica 全书: 2.5.9.
• 同时参见: Do, For, NestWhile, Nest, Fold, Select, Throw.
Further Examples

The While loop continues until the condition fails.

In[1]:=  





In[2]:=  



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.