Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Check if a list of indices is a valid position in an expression
ResourceFunction["PositionQ"][expr,{pos1,pos2,…}] returns True if all of the posi are valid positions. | |
ResourceFunction["PositionQ"][pos] represents an operator form of ResourceFunction["PositionQ"]. |
Test if a position exists:
In[1]:= |
Out[1]= |
This does not exist because the list is too short:
In[2]:= |
Out[2]= |
This does not exist because the list is not deep enough:
In[3]:= |
Out[3]= |
Test multiple positions at once:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
In[6]:= |
Out[6]= |
Test positions at different depths at the same time:
In[7]:= |
Out[7]= |
Heads are allowed:
In[8]:= |
Out[8]= |
Use an operator form to select elements that have a first part:
In[9]:= |
Out[9]= |
Test positions in an Unevaluated expression:
In[10]:= |
Out[10]= |
The evaluated form has no first part:
In[11]:= |
Out[11]= |
No side effects will be produced if Unevaluated is used:
In[12]:= |
Out[12]= |
This work is licensed under a Creative Commons Attribution 4.0 International License