Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
TupleIndex
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. |
Details and Options
Examples
Basic Examples (6)
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]= |
Properties and Relations (2)
Use Tuples to produce 3-tuples sorted by maximal element:
| In[8]:= |
| Out[8]= |
TupleIndex is based on this ordering:
| In[9]:= |
| Out[9]= |
Neat Examples (2)
Find the index of a large 6-tuple:
| In[10]:= |
| Out[10]= |
Find the index of a large 111-tuple:
| In[11]:= | ![]() |
| Out[11]= |
Version History
- 2.0.0 – 20 December 2019
- 1.0.0 – 02 December 2019
Related Resources
Related Symbols
License Information
This work is licensed under a Creative Commons Attribution 4.0 International License
![ResourceFunction[
"TupleIndex"] /@ {{999999, 999999}, {9999, 9999, 9999}, {999, 999, 999, 999}, {58, 251, 174, 151, 123}, {99, 99, 99, 99, 99, 99}, {47,
11, 16, 51, 29, 21, 41}, {21, 17, 31, 0, 18, 30, 14, 27}, {12, 1, 14, 3, 17, 21, 14, 15, 8}, {13, 15, 14, 1, 3, 13, 15, 3, 7, 0}, {3,
5, 5, 0, 8, 9, 9, 12, 8, 4, 0}, {9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}}](https://cdn.statically.io/img/www.wolframcloud.com/obj/resourcesystem/images/e57/e57e6d70-b048-4bc9-9682-e4cfc3de1232/7c641f573f8f9223.png)
![ResourceFunction[
"TupleIndex"][{4, 4, 4, 4, 6, 5, 4, 7, 1, 0, 3, 1, 1, 1, 2, 6, 2, 6, 6, 6, 6, 3, 1, 3, 1, 4, 7, 3, 6, 3, 1, 3, 2, 3, 0, 6, 1, 2, 6, 6, 3,
7, 4, 1, 1, 5, 6, 2, 1, 1, 2, 1, 4, 5, 1, 6, 3, 5, 0, 2, 3, 2, 6, 0, 7, 2, 5, 6, 3, 2, 0, 3, 2, 2, 3, 1, 3, 7, 1, 5, 2, 0, 5, 7, 6, 4,
0, 0, 0, 1, 2, 5, 1, 1, 2, 3, 1, 7, 6, 1, 6, 5, 6, 1, 6, 0, 2, 1, 1, 2, 6}]](https://cdn.statically.io/img/www.wolframcloud.com/obj/resourcesystem/images/e57/e57e6d70-b048-4bc9-9682-e4cfc3de1232/3be9d57267f0f584.png)