Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Perform bitwise operations through SK combinators
ResourceFunction["BinaryCombinator"][n, length] converts the integer n into its representative combinator in binary form of length bits. | |
ResourceFunction["BinaryCombinator"][cmb] converts the binary combinator cmb into the integer. | |
ResourceFunction["BinaryCombinator"][, cmb] displays the binary combinator cmb as a string. | |
ResourceFunction["BinaryCombinator"][, length] gives a combinator that can convert the binary combinator cmb of length bits into the Church numeral. | |
ResourceFunction["BinaryCombinator"][op, length] gives a combinator corresponding to the operator op for binary numbers of length bits. |
"SKGlyphs" | {CombinatorS,CombinatorK} | symbols used to specify combinators |
Generate a combinator that represent 5 in binary form:
In[1]:= |
Out[1]= |
Convert the combinator of 5 in binary form back into an integer:
In[2]:= |
Out[2]= |
Display the combinator of 5 in binary form as a string:
In[3]:= |
Out[3]= |
Convert the combinator of 5 in binary form into the Church numeral:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
Apply the operation BitNot to 5:
In[6]:= |
Out[6]= |
In[7]:= |
Out[7]= |
Bitwise-not a binary combinator:
In[8]:= |
Out[8]= |
Bitwise-and two binary combinators:
In[9]:= |
Out[9]= |
Bitwise-or two binary combinators:
In[10]:= |
Out[10]= |
Bitwise-xor two binary combinators:
In[11]:= |
Out[11]= |
Left-shift a binary combinator:
In[12]:= |
Out[12]= |
Right-shift a binary combinator:
In[13]:= |
Out[13]= |
Increment a binary combinator:
In[14]:= |
Out[14]= |
Decrement a binary combinator:
In[15]:= |
Out[15]= |
Plus two binary combinators:
In[16]:= |
Out[16]= |
Subtract a binary combinator from another:
In[17]:= |
Out[17]= |
Compute a binary combinator using the default glyphs S and K:
In[18]:= |
Out[18]= |
Change the glyphs:
In[19]:= |
Out[19]= |
The number of bits for all binary combinators in an evaluation should be the same:
In[20]:= |
Out[20]= |
If the number of bits of a binary combinator is too small, the result may be incorrect, wrapping around and starting over (mod 2length):
In[21]:= |
Out[21]= |
Negative numbers resulting from subtraction will also wrap around:
In[22]:= |
Out[22]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License