Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
An array of nibbles (four-bit values)
ResourceFunction["NibbleArray"][{n1,n2,…}] constructs a NibbleArray object containing the nibble values ni. | |
ResourceFunction["NibbleArray"]["string"] constructs a NibbleArray object by extracting nibble values from a Base16-encoded string. |
Create a NibbleArray from a list of nibble values:
In[1]:= | ![]() |
Out[1]= | ![]() |
Convert back to a list of nibble values:
In[2]:= | ![]() |
Out[2]= | ![]() |
Create a NibbleArray from a Base16-encoded string:
In[3]:= | ![]() |
Out[3]= | ![]() |
In[4]:= | ![]() |
Out[4]= | ![]() |
NibbleArray uses Base16 in InputForm:
In[5]:= | ![]() |
Out[5]= | ![]() |
Get the Length of a NibbleArray:
In[6]:= | ![]() |
Out[6]= | ![]() |
Extract parts of a NibbleArray:
In[7]:= | ![]() |
Out[7]= | ![]() |
In[8]:= | ![]() |
Out[8]= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
Extract a sequence of nibbles:
In[10]:= | ![]() |
Out[10]= | ![]() |
Reverse a nibble array:
In[11]:= | ![]() |
Out[11]= | ![]() |
In[12]:= | ![]() |
Out[12]= | ![]() |
NibbleArray is a wrapper around a packed array:
In[13]:= | ![]() |
Out[13]= | ![]() |
In[14]:= | ![]() |
Out[14]= | ![]() |
Convert a ByteArray to a NibbleArray:
In[15]:= | ![]() |
In[16]:= | ![]() |
Out[16]= | ![]() |
In[17]:= | ![]() |
Out[17]= | ![]() |
In[18]:= | ![]() |
Out[18]= | ![]() |
In Ethereum's yellow paper, hex-prefix encoding is defined as an efficient method of encoding an arbitrary number of nibbles as a byte array:
In[19]:= | ![]() |
In[20]:= | ![]() |
Out[20]= | ![]() |
In[21]:= | ![]() |
Out[21]= | ![]() |
NibbleArray only accepts a List of integers between 0 and 15, or a Base16-encoded string:
In[22]:= | ![]() |
Out[22]= | ![]() |
In[23]:= | ![]() |
Out[23]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License