6.57 How to change the head of a list?

A list has a Head at its zero index position

lst = {1, 2, 3}; 
Head[lst] 
 
Out[242]= List 
 
lst[[0]] 
Out[243]= List
 

By changing the head we use Apply. For example, to add the numbers of the above lst, we need to change the Head from List to Plus. There is a command in Mathematica to change the Head, called Apply

Plus @@ lst 
 
Out[244]= 6
 

We could have used the zero index trick, but it is better to use Apply:

lst[[0]] = Plus 
Out[245]= Plus 
 
lst 
Out[246]= 6
 

If we have a list of lists, like this

lst = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} 
Out[247]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
 

And we wanted to change the head of each list in it, for example, we want the product of each list shown, then we need to change the head of each list to Times. To do that, the follwing short but might be strange looking command

Apply[Times, lst, {1}] 
Out[248]= {6, 120, 504}
 

Another way to do the above is to Map the Apply function

(Times @@ #1 & ) /@ lst 
Out[249]= {6, 120, 504}
 

or, little shorter version of the above:

(Times @@ #1 & ) /@ lst 
Out[250]= {6, 120, 504}