FunctionToApplication[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]]]
In[]:=
s[Application]s[Application]s[Application]s[Application]k[Application]s[Application]s[Application]s[Application]s[Application]s[Application]k[Application]s[Application]s[Application]s[Application]s[Application]s[Application]s[Application]s[Application]s[Application]k[Application]s[Application]s[Application]s[Application]s[Application]s
Out[]=
FunctionToApplication[a[b[c[d[e]]]]]
In[]:=
a[Application]b[Application]c[Application]d[Application]e
Out[]=
InputForm[%]
In[]:=
a [Application] (b [Application] (c [Application] (d [Application] e)))
Out[]//InputForm=
FunctionToList[a[b[c[d[e]]]]]/.Listf
In[]:=
f[a,f[b,f[c,f[d,e]]]]
Out[]=
FunctionToList[a[b][c][d][e]]/.Listf
In[]:=
f[f[f[f[a,b],c],d],e]
Out[]=
%33//.(f[x_,y:f[_,_]]f[x,p[y]])
In[]:=
f[a,p[f[b,p[f[c,p[f[d,e]]]]]]]
Out[]=
CombinatorString[expr_,dir:(Right|Left),char_]:=Enclose[Module[{f,p,r},r=ConfirmQuiet[<|Rightf[x:f[_,_],y_]f[p[x],y],Leftf[x_,y:f[_,_]]f[x,p[y]]|>[dir]];expr//.(h_?(!ListQ[#]&))[x_]f[h,x]//.r//.{p[x_]RowBox[{"(",x,")"}],f[x_,y_]RowBox[{x,char,y}]}]]
In[]:=
CombinatorString[a[b][c][d][e],Right,"⊙"]//DisplayForm
In[]:=
(((a⊙b)⊙c)⊙d)⊙e
Out[]//DisplayForm=
CombinatorString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Right,"@"]//DisplayForm
In[]:=
(s@(s@s@s)@(k@(s@s@s)@s)@s)@((k@(s@s@s)@s)@s)@(s@s@s)@(k@(s@s@s)@s)@s
Out[]//DisplayForm=
CombinatorString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Right,""]//DisplayForm
In[]:=
(s(sss)(k(sss)s)s)((k(sss)s)s)(sss)(k(sss)s)s
Out[]//DisplayForm=
ToString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]]]//StringLength
In[]:=
73
Out[]=
"(s@(s@s@s)@(k@(s@s@s)@s)@s)@((k@(s@s@s)@s)@s)@(s@s@s)@(k@(s@s@s)@s)@s"//StringLength
In[]:=
707
Out[]=
StringReplace[ToString[CombinatorString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Right,""]//DisplayForm]," """]//StringLength
In[]:=
45
Out[]=
StringReplace[ToString[CombinatorString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Right,"@"]//DisplayForm]," """]//StringLength
In[]:=
69
Out[]=
StringReplace[ToString[CombinatorString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Right,"@"]//DisplayForm]," """]
In[]:=
(s@(s@s@s)@(k@(s@s@s)@s)@s)@((k@(s@s@s)@s)@s)@(s@s@s)@(k@(s@s@s)@s)@s
Out[]=
StringCount[%,"("]
In[]:=
10
Out[]=
StringCount[ToString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]]],"["]
In[]:=
24
Out[]=
FunctionToApplication[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]]]
In[]:=
s[Application]s[Application]s[Application]s[Application]k[Application]s[Application]s[Application]s[Application]s[Application]s[Application]k[Application]s[Application]s[Application]s[Application]s[Application]s[Application]s[Application]s[Application]s[Application]k[Application]s[Application]s[Application]s[Application]s[Application]s
Out[]=
ToString[%]
In[]:=
s [Application] (s [Application] (s [Application] s) [Application] (k [Application] (s [Application] (s [Application] s) [Application] s) [Application] s)) [Application] (k [Application] (s [Application] (s [Application] s) [Application] s) [Application] s [Application] (s [Application] (s [Application] s) [Application] (k [Application] (s [Application] (s [Application] s) [Application] s) [Application] s)))
Out[]=
StringCount[%,"("]
In[]:=
13
Out[]=
CombinatorString[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Left,""]//DisplayForm
In[]:=
s(s(ss)(k(s(ss)s)s))(k(s(ss)s)s(s(ss)(k(s(ss)s)s)))
Out[]//DisplayForm=
CombinatorParenCount[expr_,dir:(Right|Left)]:=Enclose[Module[{f,p,r},r=ConfirmQuiet[<|Rightf[x:f[_,_],y_]f[p[x],y],Leftf[x_,y:f[_,_]]f[x,p[y]]|>[dir]];Count[expr//.(h_?(!ListQ[#]&))[x_]f[h,x]//.r,p,{0,Infinity},HeadsTrue]]]
In[]:=
CombinatorParenCount[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Left]
In[]:=
13
Out[]=
CombinatorParenCount[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],Right]
In[]:=
10
Out[]=
Groupings[Table[s,4],Construct2]
In[]:=
{s[s][s][s],s[s[s][s]],s[s[s]][s],s[s[s[s]]],s[s][s[s]]}
Out[]=
CombinatorParenCount[#,Left]&/@Groupings[Table[s,4],Construct2]
In[]:=
{0,1,1,2,1}
Out[]=
CombinatorParenCount[#,Right]&/@Groupings[Table[s,4],Construct2]
In[]:=
{2,1,1,0,1}
Out[]=
CombinatorParenCount[#,Right]&/@Groupings[Table[s,6],Construct2]
In[]:=
{4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0,3,2,2,1,3,2,3,2,2,1,2,1,3,3,2,2,2,2,1,1,2,2,3,2,2,1}
Out[]=
CombinatorParenCount[#,Left]&/@Groupings[Table[s,6],Construct2]
In[]:=
{0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,1,2,1,2,2,3,2,3,1,1,2,2,2,2,3,3,2,2,1,2,2,3}
Out[]=
Counts[%]
In[]:=
01,110,220,310,41
Out[]=
CombinatorParenCount[#,Right]&/@Groupings[Table[s,6],Construct2]
In[]:=
{4,3,3,2,3,2,2,1,3,2,2,1,2,1,1,0,3,2,2,1,3,2,3,2,2,1,2,1,3,3,2,2,2,2,1,1,2,2,3,2,2,1}
Out[]=
Counts[%]
In[]:=
41,310,220,110,01
Out[]=
Table[KeySort[Counts[CombinatorParenCount[#,Left]&/@Groupings[Table[s,n],Construct2]]],{n,8}]
In[]:=
{,01,01,11,01,13,21,01,16,26,31,01,110,220,310,41,01,115,250,350,415,51,01,121,2105,3175,4105,521,61}
Out[]=
Table[Mean[CombinatorParenCount[#,Left]&/@Groupings[Table[s,n],Construct2]],{n,8}]
In[]:=
Mean[{}],0,
1
2
,1,
3
2
,2,
5
2
,3
Out[]=
FactorInteger[01,121,2105,3175,4105,521,61]
In[]:=
0{{1,1}},1{{3,1},{7,1}},2{{3,1},{5,1},{7,1}},3{{5,2},{7,1}},4{{3,1},{5,1},{7,1}},5{{3,1},{7,1}},6{{1,1}}
Out[]=
Count[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],_[_],{0,Infinity},HeadsTrue]
In[]:=
24
Out[]=
Count[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],_[_][_],{0,Infinity},HeadsTrue]
In[]:=
10
Out[]=
Count[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],_[_][_],{0,Infinity},HeadsTrue]
Count[s[s[s[s]][k[s[s[s]][s]][s]]][k[s[s[s]][s]][s][s[s[s]][k[s[s[s]][s]][s]]]],_[_[_]],{0,Infinity},HeadsTrue]
In[]:=
RGBColor[1, 1, 0]
Out[]//InputForm=