Functional Constructs : Map, Apply ...

?Map

Clear[h,f,t,l]

l={"a","b",3,4,{-5,x,Exp[Pi]},f[6],t[5]}

Map[h,l]

TreeForm[l]

Map[h,l]//TreeForm

The third argument of Map specificies the level(s) at which to Map

Map[h,l,{2}]

Map[h,l,{2}]//TreeForm

Map[h,l,{1,2}]

Map[ {#,Sqrt[#]}&, l ]//MatrixForm

Correct? equivalent?

Map[v[#]&,l]
Map[v[#],l]
Map[v&,l]
Map[v,l]

Map[ v, 
{
{1,2,3},
{4,5,6}
}
]//MatrixForm

Map[ v, 
{
{1,2,3},
{4,5,6}
},
{2}
]//MatrixForm

Map[ v, 
{
{1,2,3},
{4,5,6}
},
Infinity
]//MatrixForm

Map[ v[#]&, 
{
{1,2,3},
{4,5,6}
},
Infinity
]//TreeForm

MapAll[ v[#]&, 
{
{1,2,3},
{4,5,6}
}
]

Map works on all expressions, not just lists.

exp= a + Sin[x Exp[1/2 Pi]] -Cos[y]

exp//TreeForm

Map[v,exp]

t[23,kk,63]//TreeForm

Map[v, t[23,kk,63]]

Map[v,1+Pi+c]

Map[v, t[23,kk,63], Heads->True]

A list of random integers

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

Is there any prime number in the list?

Map[v,l]

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

Map[PrimeQ,l]

?Select

Select[l,PrimeQ]

Is there any number divisible by 17?

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

(n, Exp[n]) ?

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

Sin[n]/n?

Map[Sin[#]/#&,l]

Returning the n-th power of function Sin[x_]?

Map[,l]

Function[{x},Sin[x]^]

Map[
Function[{x},Sin[x]^#]&,
l
]

extract and evaluate?

Map[Function[{x},Sin[x]^#]&,l][[2]][2.]

A list of functions

lf={Sin,Cos,#^3-#&,Integrate[(1-x^2)/x^2,{x,1,#}]&}

Map[v,lf]

Evaluating each function in Pi?

Map[#[Pi]&,lf]

l1={a,b,c,d,e};
l2={1,2,3,4,5};

How to form {a,(b^2),(c^3),(d^4),(e^5)} ?

Map[#^#2&,l1,l2]

Map[v,{l1,l2}]

Map[#^#2&,{l1,l2}]

{l1,l2}//MatrixForm

{l1,l2}//Transpose

Map[v,Transpose[{l1,l2}]]

Map[#[[1]]^#[[2]]&,Transpose[{l1,l2}]]

Apply each function to the corresponding point

lf
lx={x,y,0.,Pi}

Transpose[{lf,lx}]

Map[v,Transpose[{lf,lx}]]

#[[1]][#[[2]]]&

Map[#[[1]][#[[2]]]&,Transpose[{lf,lx}]]

MapIndexed[] provides a second argument (the position) to the function.
This argument is a list, and is accessed through #2

Map[v,{a,b,c,d,e}]
MapIndexed[v,{a,b,c,d,e}]

MapIndexed[ #1^#2[[1]]&, {a,b,c,d,e}]

TreeForm[{{a,b},{c,d},e}]

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

MapThread[]

l1={1,2,3,4};
l2={a,b,c,d};
l3=Table[Random[],{4}];

MapThread[ t, {l1,l2,l3}]

n=5;
lx=RandomReal[1,n];
ly=RandomReal[1,n];
lz=RandomReal[1,n];

funD[(Subscript[x, i]), (Subscript[y, i]), (Subscript[z, i])] ?

MapThread[funD,{lx,ly,lz}]

MapThread[funD[{#1,#2,#3}]&,{lx,ly,lz}]

functions^power[argument]

f={Sin,#^-2&,Exp,#^3-#&};
g={2,3,2,1};
h={Pi,E,I,4};

Map? MapThread?

Map[v,Transpose[{f,g,h}]]

Map[#[[1]][#[[3]]]^#[[2]]&,Transpose[{f,g,h}]]

MapThread[#1[#3]^#2&,{f,g,h}]

Apply[] passes all the arguments to a function

Apply[ff,{1,2,3,4,5}]

Apply[Times,{a,2,b,4}]

Apply[Plus,{{1,a},{2,b},{4,d}}]

Apply[Join,{{2,3},{1},{2,3},{4,5}}]

Apply[Union,{{2,3},{1},{2,3},{4,5}}]

Clear[g]

Syntax

Map[g,{arg0,arg1,arg2}]
g/@{arg0,arg1,arg2}

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

Map[t,l1]

t@l1

t/@l1

t@@l1

More:  Inner[], Outer[], Thread[]...

Inner[Times,{1,2,3,4},{a,b,c,d},Plus]  (* inner product *)

Inner[Plus,{1,2,3,4},{a,b,c,d},Times]

Inner[{#1,#2}& ,{1,2,3,4},{a,b,c,d},Plus]

Select[], Cases[], Position[], Count[]...

?Select

Select[
Table[Random[],{10}],
#>.5&]

Cases[{a, a^b, 3^Pi, Pi^3}, _^_]

Position[{a, a^b, 3^Pi, Pi^3}, _^_]