a+b c

(Pi^f[2,3,4,2])/f[-1,1]/.
f[x__,n_Integer]/;Length[{x}]>n->g[x]

(Pi^f[2,3,4,2])/f[0,0,1]/.
f[x__,n_Integer]/;Length[{x}]>n->g[x]

Map[
{#[[1]][#[[1]][#[[2]]]]}&,
{{#^2-1&,2},{(#-1)(#+1)&,-2}}
]

Plot3D[
ABC[x,y],{x,-2.5,2.5},{y,-2.5,2.5},
PlotPoints->50]

ContourPlot[
ABC[x,y],{x,-2.5,2.5},{y,-2.5,2.5},
PlotPoints->100]

ABC[x_,y_]/;x^2+y^2≤1:=x^2+y^2

ABC[x_,y_]/;x^2+y^2≤4:=Cos[Sqrt[x^2+y^2]]

ABC[x_,y_]/;x≤0&&y≤0:=Pi

ABC[x_,y_]:=0

?ABC

Map[f&,{a,b,c,1,2,3}]

listR={a->b, f[x__,n_Integer]->g[x]}

Map[
#/.(lhs_->rhs_)->(rhs->lhs)&,
listR
]

listR/.(lhs_->rhs_)->(rhs->lhs)

4 1+

FullForm[a->b]

listR/.Rule[a_,b_]->Rule[b,a]

Map[Rule[#[[2]],#[[1]]]&,listR]

Map[#[[2]]->#[[1]]&,listR]

exp=a+b c

FullForm[a+b c]

(a+b c )[[2,2]]

?Apply

?Map

@

a~f~b

4 2+ 3 4+ 2 8+16

Plus@@(2^{1,2,3,4,1,2,3,1,2,1})

exp={1,{b, c},{2, {Sin[Exp[b]]},{c,2}}}

TreeForm[exp]

Depth[exp]

Flatten[exp]//TreeForm

perm=RandomSample[Range[10]]

findCycles[perm]

MapIndexed[h,perm]

step0=MapIndexed[{First[#2],#1}&,
perm
]

step0/.
{l___,{a__,b_},m___,{b_,c__},r___}->
{l,{a,b,c},m,r}

step0//.
{l___,{a__,b_},m___,{b_,c__},r___}->
{l,{a,b,c},m,r}

(step0//.
{l___,{a__,b_},m___,{b_,c_},r___}->
{l,{a,b,c},m,r})//.
{l___,{a_,m___,a_},r___}->{l,{a,m},r}

(step0//.
{l___,{a__,b_},m___,{b_,c_},r___}->
{l,{a,b,c},m,r})/.{a_,m___,a_}->{a,m}

findCycles[perm_]:=
Map[Length,
((MapIndexed[{First[#2],#1}&,perm]//.
{l___,{a__,b_},m___,{b_,c_},r___}->
{l,{a,b,c},m,r})/.{a_,m___,a_}->{a,m})]//Max

cycleMax[size_,n_]:=
Map[
findCycles,
Table[
RandomSample[Range[size]],
{n}
]
]//Sort//Tally//ListPlot

cycleMax[40,5000]

1653./10000

1./6

Palyndromes

exp1={1,2,3,a,b,a,3,2,1};
exp2={1,2,3,a,a,3,2,1};
exp3={1,2,3,a,b,b,3,2,1};

Clear[paly]

paly[{a_,m___,a_}]:=paly[{m}]

paly[{}]:=True
paly[{_}]:=True
(*paly[{__}]:=False*)
paly[_]:=False

paly[exp1]
paly[exp2]
paly[exp3]