Mathematica 9 is now available

NestWhileList

Usage

NestWhileList[f, expr, test] 用来生成一个以expr开始,然后重复使用f 直至把test应用到该结果不再得到True为止的结果列表
NestWhileList[f, expr, test, m]提供最近的m个结果作为每一步test的参数.
NestWhileList[f, expr, test, All]提供迄今为止的所有结果作为每一步test的参数.
NestWhileList[f, expr, test, m, max]f 至多应用 max 次.


Notes

• 由NestWhileList[f, expr, test]返回的列表中的最后一个元素总是一个被应用到test上不返回True的表达式.
NestWhileList[f, expr, test, m] 在每一步对 test[ ,  , ... ,  ]进行计算. 它不把结果  放在一个列表中.
 以它们被生成的顺序给出, 最近的跟在最后.
• 直到至少有m个结果已被生成时,NestWhileList[f, expr, test, m]才开始应用test.
• 直到至少有mmin个结果已被生成时,NestWhileList[f, expr, test,  mmin, m ]才开始应用test.然后它在每一步为test提供不超过m的尽可能多的最近结果作为参数.
NestWhileList[f, expr, test, m] 等价于 NestWhileList[f, expr, test,  m, m ].
NestWhileList[f, expr, UnsameQ, 2] 等价于 FixedPointList[f, expr].
NestWhileList[f, expr, test, All] 等价于 NestWhileList[f, expr, test,  1, Infinity ].
NestWhileList[f, expr, UnsameQ, All] 不断应用 f 直至相同结果首次出现不止一次.
NestWhileList[f, expr, test, m, max, n]f 额外应用 n 次, 并把该结果添加到列表中.
NestWhileList[f, expr, test, m, max, -n] 从所生成的列表中丢掉最后 n 个元素.
• 参见Mathematica 全书: 2.2.2节.
• 同时参见: NestWhile, FixedPointList, NestList, While.
Further Examples

This gives the list of consecutive integers starting at  up to the next integer that is prime.

In[1]:=  

Out[1]=

 is the  th integer counting from  .

In[2]:=  

Out[2]=

Here is a function that takes a single step in the Newton approximation to  .

In[3]:=  

This repeatedly applies step, stopping when  successive results are no longer considered unequal, just as in FixedPointList.

In[4]:=  

Out[4]=

In[5]:=  

Out[5]=

Here are two more ways to get the same result.

In[6]:=  

Out[6]=

In[7]:=  

Out[7]=



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.