Exit[]

h[x_]:= 2 x

h[x_,y_]:={y,x}

{
h[3],
h[{3}],
h[{{{3}}},"three"],
h[1,2,3]
}//ColumnForm

h[arg__]:=Reverse[{arg}]

?h

{
h[1,2,3],
h[{1},{2},{3},{4,5,6},7,8],
h[],
h[h[a,b],h[a]],
h[{}],
h[{a,b,c}]
}//ColumnForm

h[arg___]:=Length[{arg}]

How to return the second argument?

Clear[hh]

hh[arg__]:={arg}[[2]]

hh[4,5,6]

hh[3,4,5,6,7,8,99,01,3,4,5,,7]

hh[3]

hh[x_,y_,z___]:=y

hh[_,y_,___]:=y

hh[arg__]/;Length[{arg}]≥2:={arg}[[2]]

How to return the penultimate (second last) argument?

Clear[hh]

hh[arg__]/;Length[{arg}]≥2:={arg}[[-2]]

hh[___,y_,_]:=y

f[arg__]:=arg

f[3,2,1]

f[x_,y_/;g[x,y]]
f[x_,y_]/;g[x,y]
f[x_/;h[x],y_/;g[y]]

function[left_,a_,b_,right_]/;b<a:=
function[left,b,a,right]

function[1,2,3,1,2,3,10,1,2,3,-10]

function[1,-1,3,-2]

function[1,-1,-3,-2]

Clear[function]

function[left__,a_,b_,right__]/;b<a:=
function[left,b,a,right]

function[9,2,3,1,2,3,10,1,2,3,-10]

Clear[function]

function[left___,a_,b_,right___]/;b<a:=
function[left,b,a,right]

function[x___]:={x}

function[9,2,3,1,2,3,10,1,2,3,-10]

?function

Replacement Rules

Clear[x,a,y]

exp1->exp2

exp1->exp2//FullForm

x=3+a

x/.a->5

x

x/. 3->5

33+a/. 3->5

3+3+a/. 3->5

3+a/.3->5

what not to do

x

x/.x->-10

x+10/.x->-10

a/.x->5

3+a/.x->5

x/. 3+a->5

3+a

a+3

x

x/.a->x

x+y/.a->y

x/.{a->2,a->4}

x/.{a->2,3->4}

x+Exp[a]/.{a->2,3->4}

x+y/.{a->y,y->4}

//.

x+y//.{a->y,y->4}

(x+y/.{a->y,y->4})/.{a->y,y->4}

x

x+y//.{a->y,y->a}

x+y//.{a->y,y->2a}

(x+y/.{a->y})/.y->a

x+y/.{a->y}/.y->a

x+y/.{{a->y},{y->a}}

{3a,a^2,3^a,a^a,a!}/.a->z

{3a,a^2,3^a,a^a,a!}/.a->4

{3a,a^2,3^a,a^a,a!}/.a^_->Infinity

{3a,a^2,3^a,a^a,a!}/._^_->Infinity

{3a,a^2,3^a,a^a,a!}/.a_^b_->b^a

{3a,a^(2+Sin[5]),(3/Cos[5])^a,a^a,a!}/.a_^b_->b^a

{3 a,(((n[5]))^a),(a^(3 Sec[5])),(a^a),a!}

Clear[x,a,y]

p[x_]:=x^3-Pi x^2 + -2 Pi x +3

Plot[p[x],{x,-Pi,3/2 Pi}]

sol=Solve[p'[x]==0,x]//N

p[x]/.sol

p'[y]/.sol

ParametricPlot[
{Sin[u]u ,Cos[u]u}, 
{u,0,100}
]

Options[ParametricPlot]

exp1=exp2;
exp1:=exp2;

exp1->exp2;
exp1:>exp2;

ParametricPlot[
{Sin[u]u ,Cos[u]u}, 
{u,0,100},
PlotPoints->125,
Axes->False,
ColorFunction->(ColorData["Rainbow"][#3]&),
MaxRecursion->0,
PlotStyle->Thick
]

options[program]={opt1->val1, opt2->val2};

program[x_,y_,opt___]:=
definition/.{opt}/.options[program]

list=RandomInteger[20,{8}]

list/.{a_,b_}/;a>b->{b,a}

list/.{left___,a_,b_,right___}/;a>b->{left,b,a,right}

list//.{left___,a_,b_,right___}/;a>b->{left,b,a,right}

list=RandomInteger[10,{30}]

list

list/.
{left___,a_,b_,right___}/;(b==a+5||b==a-5)->{a,b}

ReplaceList[
list,
{left___,a_,b_,right___}/;(b==a+5||b==a-5)->{a,b}
]

ReplaceList[
{1,2,3,4,5,6},
{x___,y___,z_}->{{x},{y},{z}}
]//ColumnForm

list=RandomInteger[10,{50}]

ReplaceList[
list,
{___,seq__,___}/;Apply[Plus,{seq}]==24->{seq}
]//ColumnForm