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};

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

paly[{_}]:=True

paly[{}]:=True

paly[_]:=False

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

paly[{Pi,Pi,1,1,2,1,1,Pi,Pi}]

#^2&[3]

#1+#2&[Pi,E]

Length[##]&[1,2,3,4]

Length[{##}]&[1,2,3,4]

Length[##]&[{1,2,3,4}]

Length[#]&[{1,2,3,4}]

Function[{t},t^2][2]

f[t]^k

fff[f_,k_]:=Function[{t},f[t]^k]

fff[Sin[t],4]

fff[Sin[t],4][3.]

fff[Sin,4][3.]

fff[Sin[#]&,4][3.]

Sin[3.]^4

fff[f_,k_]:=Function[{t},#1[t]^#2]

Clear[fff]

fff[f_,k_]:=f[#]^k&

Plot[t Sin[t],{t,0,Pi}]

fff[# Sin[#]&,3]

fff[# Sin[#]&,3][2.]

(# Sin[#])^3&[2.]

Range[12]

input=RandomSample[Range[12]]

Map[h[#]&,input]

MapIndexed[h[#1,#2]&,input]

(start=MapIndexed[{#2[[1]],#1}&,input])//ColumnForm

start

cycle[
{left___,{a_,b_},middle___,{b_,c_},right___}
]:=
cycle[{left,middle,right,{a,b,c}}]

cycle[start]

cycle[
{left___,{a_,d___,b_},middle___,{b_,e___,c_},right___}
]:=
cycle[{left,middle,right,{a,d,b,e,c}}]

cycle[start]

Clear[cycle]

cycle[
{left___,{a___,b_},middle___,{b_,c___},right___}
]:=
cycle[{left,middle,right,{a,b,c}}]

cycle[start]

Clear[cycle]

cycle[
{left___,{a__,b_},middle___,{b_,c__},right___}
]:=
cycle[{left,middle,right,{a,b,c}}]

cycle[
{left___,{a__,b_},middle___,{b_,c_},right___}
]:=
cycle[{left,middle,right,{a,b,c}}]

cycle[start]

cycle[{left___,{a_,m___,a_},right___}]:=
cycle[{left,{a,m},right}]

cycle[start]

cycle[x_]:=x

cycle[start]

cycle[
MapIndexed[{#2[[1]],#1}&,
RandomSample[Range[8]]
]
]

(input=RandomInteger[{1,20},{15,4}])//TableForm

{l___,a_,m___,b_,r___}/;Apply[Plus,a]<Plus@@b

Sort[input,Plus@@#1> Plus@@#2&]//ColumnForm

Map[Plus@@#&,
Sort[input,Plus@@#1> Plus@@#2&]
]

Map[{Plus@@#,#}&,
Sort[input,Plus@@#1> Plus@@#2&]
]//ColumnForm

step[{a_,b_,c_},{x_,y_}]:=
{y-Sign[x]Sqrt[Abs[b x -c]],
a-x}

Nest[f,x0,5]

NestList[f,x0,5]

ListPlot[
NestList[step[{.4,1,1},#]&,{0.,0.},50000]
]

ListPlot[
NestList[step[{1.4,1.1,2.2},#]&,{.2,.99},50000],AspectRatio->Automatic
]