Skip to content

While

While[cond, body] evaluates cond, and if it returns True, evaluates body. This happens repeatedly.

Attributes[While] := {HoldAll, Protected}

Simple examples

In[1]:= a = 1
Out[1]= 1
In[2]:= While[a != 5, a = a + 1]
Out[2]= Null
In[3]:= a
Out[3]= 5