Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Compute the index of a given tuple of non-negative integers
ResourceFunction["TupleIndex"][tuple] returns the index of tuple as it would appear in a list of all integer tuples of the same length, sorted by the maximal element. |
Get the index of a 3-tuple:
| In[1]:= |
| Out[1]= |
Get the index of a 3-tuple with a larger element:
| In[2]:= |
| Out[2]= |
Show by example how element sizes and positions affect ordering:
| In[3]:= |
| Out[3]= |
Indices of 2-tuples sorted by maximal element:
| In[4]:= |
| Out[4]= |
Indices of 3-tuples sorted by maximal element:
| In[5]:= |
| Out[5]= |
Show the tuples as they would be sorted by TupleIndex:
| In[6]:= |
| Out[6]= |
Find indices of some larger k-tuples:
| In[7]:= | ![]() |
| Out[7]= |
Use Tuples to produce 3-tuples sorted by maximal element:
| In[8]:= |
| Out[8]= |
TupleIndex is based on this ordering:
| In[9]:= |
| Out[9]= |
Find the index of a large 6-tuple:
| In[10]:= |
| Out[10]= |
Find the index of a large 111-tuple:
| In[11]:= | ![]() |
| Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License