Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Sort a list of patterns according to their precedence
ResourceFunction["PatternSort"][{patt1,patt2,…}] returns the patti in order of most specific to least specific. |
Sort patterns for one argument or a sequence of arguments:
In[1]:= |
Out[1]= |
For definite types of arguments:
In[2]:= |
Out[2]= |
Arguments with a head f:
In[3]:= |
Out[3]= |
Sequences of arguments:
In[4]:= |
Out[4]= |
For ambiguous matches:
In[5]:= |
Out[5]= |
The patterns do not need to be in a List:
In[6]:= |
Out[6]= |
Repeated names add specificity:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License