Map[f,{a,b,Pi,3,3.,x+y}]

Map[f,{{a,b},{Pi,3,3.},{x+y}}]

Map[f,{{a,b},{Pi,3,3.},{x+y}},{2}]

Map[f,{{a,b},{Pi,3,3.},{x+y}},{3}]

TreeForm[{{a,b},{Pi,3,3.},{x+y}}]

l = RandomInteger[{10^3,10^4},{19}]

PrimeQ[6]

TreeForm[l]

Depth[l]

Map[PrimeQ,l]

ll:= RandomInteger[{10^3,10^4},{19}]

ll

ll

l

Pure Functions

#&

#&[Pi]

#^2+#&[Pi]

#1^2 #2&[Pi,3]

N[#1^2 #2]&[Pi,3]

#1^2 #2&[Pi,3.]

{{2965,False},...,{2011,True},...}

Map[{#,PrimeQ[#]}&,l]

{#,PrimeQ[#]}&[Pi]

TreeForm[{#,PrimeQ[#]}&]

Function[{t},{t,PrimeQ[t]}][1234]

l

Map[{#,Mod[#,17]==0}&,l]

Select[l,Mod[#,17]==0&]

Map[{#,N[Exp[#],5]}&,l]

Integrate[(1-x^2)/x^2,{x,1,#}]&

lF={Sin,Cos,#^2+#&,Integrate[(1-x^2)/x^2,{x,1,#}]&};

Pi

Map[lF,Pi]

Map[#[Pi]&,lF]

Map[#@Pi&,lF]

#[Pi]&/@lF

#@Pi&/@lF

lF//Length

lF

lP={1.2,2.3,-Pi,4}

{lF[[1]][lP[[1]]],
lF[[2]][lP[[2]]], ..., }

For, While, Table, Do

MapIndexed

Map[g,{a,b,c,d,e,f}]

MapIndexed[g,{a,b,c,d,e,f}]

MapIndexed[g,{{a,b},{c,d,e},{f}},{2}]

Map[lF[[#]][lP[[#]]]&,{1,2,3,4}]

Range[Length[lF]]

Map[lF[[#]][lP[[#]]]&,Range[Length[lF]]]

{lP,lF}//Transpose

Map[#1[#2]&,Transpose[{lF,lP}]]

Map[#&,Transpose[{lF,lP}]]//ColumnForm

Map[#[[1]][#[[2]]]&,Transpose[{lF,lP}]]//ColumnForm

MapThread[f,{lP,lF}]//ColumnForm

lE={12,13,21,19};

{lF[[1]][lP[[1]]]^lE[[1]],
lF[[2]][lP[[2]]]^lE[[2]],...,}

MapThread[f,{lP,lF,lE}]//ColumnForm

MapThread[N[#2[#1]^#3]&,{lP,lF,lE}]//ColumnForm

l

Exp[#]^n&

{Exp[#]^2965&,Exp[#]^7290&,...,}

Function[{arg},def][arg]

Map[Exp[#&]^#&,l]

Map[Exp[#&]^#&,l][[2]][2.1]

Map[
Function[{t},Exp[t]^#]&,
l
]

Map[
Function[{t},Exp[t]^#]&,
l
][[2]][2.1]

Exp[2.1]^7290

h[x__]:= Length[{x}]

{h[Pi],h[1.],h[{1.}],h[1,Pi,2,x,x+y]}

h2[x__]:= Plus[x]

h2[1,Pi,2,x,x+y]

How to return the 2nd argument of hh?

hh1[x__]:={x}[[2]]

hh1[a,b,c,d,e]

hh1[a]

hh1[a,b]

hh2[_,pi_,__]:=pi

hh2[a,b,c,d,e]

hh2[a]

hh2[a,b]

hh3[_,pi__]:={pi}[[1]]

hh3[a,b,c,d]

hh3[a]

hh3[a,b]

Clear[hh]

How to return the penultimate argument of hh?

hh[__,a_,_]:=a

hh[a,b,c,d,e,f]

hh[f]

hh[e,f]

hh[a__,_]:=Last[{a}]

hh[e,f]

hh[a,b,c,e,f]

hh[e]

hh[___,a_,_]:=a

hh[e,f]

Clear[hh]

hh[args__/;Length[{args}]≥2]:={args}[[-2]]

hh[a,b,c,d,e,f]

hh[a]

hh[a,b]

hh[args__]/;Length[{args}]≥2:={args}[[-2]]

Clear[f]

f[l___,a_,b_,r___]/;a>b:=f[l,b,a,r]

f[10,2,4,1,7,-3]

f[x___]:={x}

?f

f[10,2,4,1,7,-3]

Clear[g]

g[___,a__,___]/;Plus[a]==5:={a}

g[1,2,3,-1,1,0,2,-3,1,2,-1]

Clear[h]

h[___,a__,___]/;First[{a}]+Last[{a}]==6:=Length[{a}]

h[1,2,3,-1,1,0,2,-3,1,2,-1]

Clear[h]

h[___,a_,b___,c_,___]/;a+c==10:=Length[{b}]

lN=RandomInteger[{-5,5},{10}]

Apply[h,lN]

lHT=Map[{HEAD, TAIL}[[#]]&,RandomInteger[{1,2},{10}]]

Map[{#,1}&,lHT]

Apply[compress,Map[{#,1}&,lHT]]

lHT=Map[{HEAD, TAIL}[[#]]&,RandomInteger[{1,2},{1000}]];

compress[left___,{x_,l1_},{x_,l2_},right___]:=
compress[left,{x,l1+l2},right]

compress[x___]:={x}

Apply[compress,Map[{#,1}&,lHT]]//Length

SameQ[x,x,x,x]

Clear[f]

f[x_,2 x_]:=x

f[x__]:=100

{
f[Pi,2 Pi],
f[2, 2 2],
f[Sin[1],2 Sin[1]],
f[3.14, 2 3.14],
f[x,2 x],
f[Sin[1.],2 Sin[1.]]
}//ColumnForm

Clear[f]

f[x_/;y==2 x,y_]:=x

f[x_,y_/;y==2 x]:=x

f[x_,y_]/;y==3 x:=x

{
f[Pi,3 Pi],
f[2, 3 2],
f[Sin[1],3 Sin[1]],
f[3.14, 3 3.14],
f[x,3 x],
f[Sin[1.],3 Sin[1.]]
}//ColumnForm