Patterns & Recap

t[ _[_, a_]]:= Pi

t[ f_[x_, y_]]:= {f,x,y}

?t

t[g[a,b]]

t[Sin[x,y]]

t[Sin[x+y]]

t[Sin[3+Pi]]

Sin[3+Pi]

Optional arguments

f[a_,b_,c_,mode_:"Lower"]:=
Switch[mode,
"Lower",{{a,0},{b,c}},
"Upper",{{a,b},{0,c}},
mode,Print["I don't understand you"];Abort[]
]

f[Pi,E,3]//MatrixForm

f[Pi,E,3,"Lower"]//MatrixForm

f[Pi,E,3,"lower"]//MatrixForm

2 x2 matrices

isLowerQ[M_]:=M[[1,2]]==0

isLowerQ[{{_,0},{_,_}}]:=True

isLowerQ[_]:=False

isLowerQ[f[1,2,3]]

isLowerQ[f[1,2,3,"Upper"]]

Clear[f]

f[a_^b_]:={a,b}

{
f[1^2],
f[2^1],
f[Pi^(t+y)],
f[(t+y)]
}

ff[a_^(b_:1)]:={a,b}

{
ff[1^2],
ff[2^1],
ff[Pi^(t+y)],
ff[(t+y)]
}

Clear[f]

3 x3 matrix

f[{{a_,0,0},
{b_,c_,0},
{d_,e_,f_}}]:={d,e,f}

f[{{1,2,3},{4,5,6},{7,8,9}}]

f[{{1,0,0},{4,5,0},{7,8,9}}]

g[{{_,0,0},
{_,_,0},
r:{_,_,_}}]:=r

g[{{1,0,0},{4,5,0},{7,8,9}}]

Recap

f[x_]:= (* general function definition *)

f[x_List]:= (* restricting the type of the arguments *)

f[x_,y_]:= (* multiple arguments *)

f[x_,"a"]:= (* fixing one of the arguments *)

f[x_/;NumberQ[x]]:= (* condition on argument x *)

f[x_,y_,z_/;condition[z]]:= (* condition only on argument z *)

f[x_,y_,z_]/;condition[x,y,z]:=(* condition on arguments *)

f[a_,b__,l___]:=
(* matching one element, a non-empty sequence of elements, any sequence *)

f[a_+b_]:=(* specifying the structure of the argument *)

f[{{a_,b_},___}]:=Pi (* again, specifying the structure of the argument *)

f[{0,1}]

f[{{0,1}}]

f[m:_^b_]:={m,b}
(* assigning names to parts of a pattern *)

f[{E^Pi}]

f[E^Pi]

f[a_,b_:Pi]:=Sin[a+b] (* default arguments *)

#&
#1+#2&
##&    (* triple underscore *) 
Function[{t},t^2]
Function[{t,v},t^2+v]

g/@{arg0,arg1,arg2}

g@@{arg0,arg1,arg2}

Apply[g,{arg0,arg1,arg2}]

g@{arg0,arg1,arg2}

{arg0,arg1,arg2}//g

a~g~b