Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
NestWhile analog of FoldPairList
ResourceFunction["NestWhilePairList"][f,y0,test] gives the list of successive xi obtained by applying f to yi, until applying test to the yi no longer yields True where at each step f returns {xi,yi+1}. | |
ResourceFunction["NestWhilePairList"][f,y0,test,m] supplies the most recent m results as arguments for test at each step. | |
ResourceFunction["NestWhilePairList"][f,y0,test,{mmin,m}] does not start applying test until at least mmin results have been generated. At each step it then supplies as arguments to test as many recent results as possible, up to a maximum of m. | |
ResourceFunction["NestWhilePairList"][f,y0,test,All] supplies all results so far as arguments for test at each step. | |
ResourceFunction["NestWhilePairList"][f,y0,test,m,max] applies f at most max times. | |
ResourceFunction["NestWhilePairList"][f,y0,test,m,{min,max}] returns a range of results spanning between min and up to max number of times applying f. | |
ResourceFunction["NestWhilePairList"][f,y0,test,m,minMax,n] applies f an extra n times. | |
ResourceFunction["NestWhilePairList"][f,y0,test,m,minMax,-n] returns the result found when f had been applied n fewer times. | |
ResourceFunction["NestWhilePairList"][f,y0,test,m,minMax,n,g] gives the list of successive values of g[{xi,yi}]. |
Nest a function wrapping each outcome with another, while a given condition holds:
| In[1]:= |
| Out[1]= |
Return results of applying a given function (e.g. Fibonacci) to an output of an iterating function (e.g. Prime):
| In[2]:= |
| Out[2]= |
Compare:
| In[3]:= |
| Out[3]= |
Compute intermediate quotients and remainders of the Euclidean algorithm for GCD[1071,462]:
| In[4]:= |
| Out[4]= |
Provide more arguments to the test function:
| In[5]:= |
| Out[5]= |
Iterate up to a given number of steps:
| In[6]:= |
| Out[6]= |
Return the range of steps:
| In[7]:= |
| Out[7]= |
Return last three elements:
| In[8]:= |
| Out[8]= |
Include the initial expression:
| In[9]:= |
| Out[9]= |
Apply the function extra or fewer times relative to the point of test function succeeding:
| In[10]:= |
| Out[10]= |
| In[11]:= |
| Out[11]= |
| In[12]:= |
| Out[12]= |
Use last argument to get a result of applying any function to successive pairs:
| In[13]:= |
| Out[13]= |
Evolve a combinator expression and return its plots:
| In[14]:= | ![]() |
| Out[14]= | ![]() |
The NestWhilePairList, unlike NestWhileList and FoldWhileList, does not include the last element for which the test fails:
| In[15]:= |
| Out[15]= |
| In[16]:= |
| Out[16]= |
| In[17]:= |
| Out[17]= |
| In[18]:= |
| Out[18]= |
This work is licensed under a Creative Commons Attribution 4.0 International License