Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Provide a loop construct that is similar to While, but performing the action prior to rather than after the termination test
ResourceFunction["Until"][test,body] evaluates body then test repeatedly until test returns True. |
Create a loop that increments a counter and then checks for primality:
In[1]:= |
Out[3]= |
Until can be used as an operator form:
In[4]:= |
Out[6]= |
The option MaxIterations limits the number of times the loop is repeated:
In[7]:= |
Out[9]= |
Until is very similar to While except it performs the action before the test. Also, Until terminates when the test is met and While continues until it is not met:
In[10]:= |
Out[12]= |
In[13]:= |
Out[15]= |
The equivalent While statement would be:
In[16]:= |
Out[19]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License