0
$\begingroup$

This question already has an answer here:

I'm having trouble deciphering why the following couple of expressions evaluate the way they do.

#&@@

This returns the first value of a list. Why? Naïvely I would have expected this to replace the head of the list with the list itself.

1 ## &@@

This multiplies a list together, like

Times@@

Why is that? I imagine it's for the same reason as the first shortcut.

$\endgroup$

marked as duplicate by Kuba, Jens, MarcoB, user9660, m_goldberg Jan 30 '16 at 0:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    $\begingroup$ Take a look there and at linked ref pages: What the @#%^&*?! $\endgroup$ – Kuba Jan 29 '16 at 17:38
  • 2
    $\begingroup$ It does not strictly "return the first value of a list": it just returns the first argument to the function following @@, for lists, the full form is List[x,y,z], and the 1st argument is x, which is also the first value of a list. Try # & @@ func[c, b, a] $\endgroup$ – egwene sedai Jan 29 '16 at 17:45
  • $\begingroup$ You can also try to translate short-form expressions by wrapping them in FullForm[Hold[...]]. That displays the long form from which you can go to the help pages more easily. $\endgroup$ – Jens Jan 29 '16 at 17:51
3
$\begingroup$
#&@@list === First@list

because #===#1(first argument), try #2&@@{7,6,5,4}

In the second case 1 x means Times[1,x] so the expression

1 ## &@@{5,4,3,2} === Times[1,Sequence[5,4,3,2]] == Times[1,5,4,3,1]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.