Function Repository Resource:

# CombinatorConvert

Convert between different combinator formats

Contributed by: Mano Namuduri and Jan Mangaldan
 ResourceFunction["CombinatorConvert"][cmb,format] converts a combinator expression cmb to the specified format. ResourceFunction["CombinatorConvert"][transform] interconverts a combinator transformation rule transform between the RuleDelayed and Function formats. ResourceFunction["CombinatorConvert"][transform,name] interconverts a combinator transformation rule transform using the symbol name to designate the combinator on the left-hand side when converting to RuleDelayed.

## Details

The following settings for format are supported:
 "Application" combinator represented in terms of Application,S(K(SI))(S(KK)I)xy "List" combinator represented as a list, {{{{S, {K, {S,I}}}, {{S, {K,K}}, I}}, x}, y} "Nested" combinator in nested bracket format, S[K[S[I]]][S[K[K]][I]][x][y] "String" combinator represented as a left-associative string, "S(K(SI))(S(KK)I)xy"
Accordingly, the argument cmb can be given in any of the above formats.
If transform is given as a RuleDelayed (lhsrhs), then ResourceFunction["CombinatorConvert"] will return a pure Function. If transform is given as a Function (arg body), then ResourceFunction["CombinatorConvert"] will return a RuleDelayed.
The argument name, if specified, should be given as a Symbol (default is λ).

## Examples

### Basic Examples (5)

Convert a combinator expression in application format to each of the possible formats:

 In[1]:=
 Out[1]=
 In[2]:=
 Out[2]=
 In[3]:=
 Out[3]=
 In[4]:=
 Out[4]=

Convert a combinator expression in nested bracket format to each of the possible formats:

 In[5]:=
 Out[5]=
 In[6]:=
 Out[6]=
 In[7]:=
 Out[7]=
 In[8]:=
 Out[8]=

Convert a combinator expression in list format to each of the possible formats:

 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=
 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=

Convert a combinator expression in list format to each of the possible formats (note that the conversion from string format only allows single-character symbols, so combinator glyphs would need to be inserted retroactively):

 In[13]:=
 Out[13]=
 In[14]:=
 Out[14]=
 In[15]:=
 Out[15]=
 In[16]:=
 Out[16]=

Convert between the RuleDelayed and Function formats of the CombinatorB transformation:

 In[17]:=
 Out[17]=
 In[18]:=
 Out[18]=

When converting from Function to RuleDelayed, a second argument must be supplied for the correct symbol to appear on the left-hand side:

 In[19]:=
 Out[19]=

### Possible Issues (3)

Input strings containing any symbol other than letters, digits or parentheses are currently not supported:

 In[20]:=
 Out[20]=

Input strings must be in left-associative format:

 In[21]:=
 Out[21]=

A combinator transformation must be a RuleDelayed or Function object:

 In[22]:=
 Out[22]=

## Version History

• 1.0.0 – 10 March 2021