Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Cases for matching subexpressions together with their positions
ResourceFunction["PositionCases"][expr,pattern] gives a list of all parts of expr that match the pattern. | |
ResourceFunction["PositionCases"][expr,pattern→rhs] gives the values of rhs that match the pattern. |
Find all cases matching a position pattern:
| In[1]:= |
| Out[1]= |
Find all cases matching both position and an ordinary pattern:
| In[2]:= |
| Out[2]= |
Use a rule to compute arbitrary combinations of subexpressions and their positions:
| In[3]:= |
| Out[3]= |
Find all positions deeper than specified depth:
| In[4]:= |
| Out[4]= |
Find all sub heads:
| In[5]:= |
| Out[5]= |
Use found positions for manipulation of an underlying expression:
| In[6]:= |
| Out[6]= |
Use PatternTest:
| In[7]:= |
| Out[7]= |
Return raw PositionPattern expressions:
| In[8]:= |
| Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License