Wolfram Research

Function Repository Resource:

CombinatorBracketsPlot

Source Notebook

Visualize matched brackets of a combinator

Contributed by: Wolfram Research

ResourceFunction["CombinatorBracketsPlot"][expr]

visualizes the pairing of the brackets in the combinator expr.

Details and Options

ResourceFunction["CombinatorBracketsPlot"] has the same options as Graphics, with the following additions:
Appearance Automatic overall appearance
"BracketCharacters" Automatic characters used to represent the brackets
ColorRules Automatic color rules for points corresponding to the symbols present
"IncludeTextForm" True whether to display the brackets of the combinator
PlotStyle Automatic style to use
Possible settings for the Appearance option include "Bush", "Mountain", "Tree" and "Vee".

Examples

Basic Examples (5) 

Visualize a particular combinator:

In[1]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Vee"]
Out[1]=

Do not display brackets:

In[2]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Vee", "IncludeTextForm" -> False]
Out[2]=

Use a "Mountain" appearance:

In[3]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Mountain"]
Out[3]=

Without brackets:

In[4]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Mountain", "IncludeTextForm" -> False]
Out[4]=

Use a "Bush" appearance:

In[5]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Bush"]
Out[5]=

Without brackets:

In[6]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Bush", "IncludeTextForm" -> False]
Out[6]=

Use a "Tree" appearance:

In[7]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Tree"]
Out[7]=

Without brackets:

In[8]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Tree", "IncludeTextForm" -> False]
Out[8]=

Scope (1) 

Use any symbol:

In[9]:=
ResourceFunction[
 "CombinatorBracketsPlot"][\[ScriptE][\[ScriptE][\[ScriptE]][\
\[ScriptE]]][\[ScriptE]][\[ScriptE]]]
Out[9]=

Options (5) 

Appearance (1) 

Show various visualization styles for a combinator:

In[10]:=
GraphicsGrid[
 Partition[
  Table[ResourceFunction["CombinatorBracketsPlot"][
    s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
       s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> ap, "BracketCharacters" -> {"[", "]"}, PlotLabel -> ap], {ap, {"Bush", "Mountain", "Tree", "Vee"}}], 2]]
Out[10]=

BracketCharacters (1) 

Use different bracketing characters:

In[11]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], "BracketCharacters" -> {"\[LeftAngleBracket]", "\[RightAngleBracket]"}]
Out[11]=

ColorRules (1) 

Specify color rules for points corresponding to the symbols present:

In[12]:=
GraphicsGrid[
 Partition[
  Table[ResourceFunction["CombinatorBracketsPlot"][
    s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
       s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> ap, ColorRules -> {s -> Red, k -> Blue}, PlotLabel -> ap], {ap, {"Bush", "Mountain", "Tree", "Vee"}}], 2]]
Out[12]=

IncludeTextForm (1) 

Show with and without brackets:

In[13]:=
GraphicsRow[
 ResourceFunction["CombinatorBracketsPlot"][
    s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
       s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], "IncludeTextForm" -> #] & /@ {True, False}]
Out[13]=

PlotStyle (1) 

Change the styling:

In[14]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], "IncludeTextForm" -> False, PlotStyle -> Directive[RGBColor[0.711529, 0.181058, 0.], Thick]]
Out[14]=
In[15]:=
ResourceFunction["CombinatorBracketsPlot"][
 s[k[s]][k][s[s[k[s]][k]][s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]]][
    s[s[k[s]][k]][s[s[k[s]][k]][s[k]]]][s][k], Appearance -> "Mountain", "IncludeTextForm" -> False, PlotStyle -> Directive[RGBColor[0.8505, 0.4275, 0.13185], AbsolutePointSize[4], AbsoluteThickness[1]]]
Out[15]=

Resource History

Related Resources

License Information