Function Repository Resource:

ArrayPatternFromIndex

Source Notebook

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

Contributed by: Ed Pegg Jr

ResourceFunction["ArrayPatternFromIndex"][{size,index,b}]

creates an array of the given size using the digits of index in base b.

Details

The index must be a non-negative integer.

Examples

Basic Examples (2) 

Convert size, index and base 2 into a binary array:

In[1]:=
ResourceFunction["ArrayPatternFromIndex"][{{2, 3}, 15, 2}]
Out[1]=

Convert size, index and base 3 into a ternary array:

In[2]:=
ResourceFunction["ArrayPatternFromIndex"][{{2, 4}, 95, 3}]
Out[2]=

Properties and Relations (1) 

The resource function ArrayPatternToIndex is the inverse of ArrayPatternFromIndex:

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

Version History

  • 1.0.0 – 08 July 2022

Related Resources

License Information