Function Repository Resource:

ArrayPatternToIndex

Source Notebook

Convert an integer array pattern into a size, index and base

Contributed by: Ed Pegg Jr

ResourceFunction["ArrayPatternToIndex"][array]

returns the size, integer-index representation and base of array.

Details

The integer array should have no negative values.

Examples

Basic Examples (2) 

Convert a binary array into size, index and base:

In[1]:=
ResourceFunction["ArrayPatternToIndex"][{{0, 0, 1}, {1, 1, 1}}]
Out[1]=

Convert a ternary array into size, index and base:

In[2]:=
ResourceFunction["ArrayPatternToIndex"][{{0, 0, 0, 1}, {0, 1, 1, 2}}]
Out[2]=

Properties and Relations (1) 

The resource function ArrayPatternFromIndex is the inverse of ArrayPatternToIndex:

In[3]:=
ResourceFunction["ArrayPatternToIndex"][{{0, 0, 0, 1}, {0, 1, 1, 2}}]
Out[3]=
In[4]:=
ResourceFunction["ArrayPatternFromIndex"][%]
Out[5]=

Version History

  • 1.0.0 – 08 July 2022

Related Resources

License Information