Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
The opposite of When
ResourceFunction["WhenNot"][test1,value1,test2,value2,…][e] evaluates each of the testi[e] in turn, returning the value of the valuei corresponding to the first test that does not yield True; otherwise, it yields e unchanged. |
WhenNot evaluates the corresponding value only when the specified condition is not met:
In[1]:= | ![]() |
In[2]:= | ![]() |
Out[2]= | ![]() |
Use a single test with WhenNot:
In[3]:= | ![]() |
Out[3]= | ![]() |
In[4]:= | ![]() |
Out[4]= | ![]() |
Try several tests in turn:
In[5]:= | ![]() |
Out[5]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License