This is a rather general question, which I fail to answer myself. I guess it is mainly due to my insufficient knowledge of the precise terms.
If I understand correctly, the following are equivalent:
f = Function[u, 3 + u]
f = Function[3 + #]
f = (3+#) &
f[x_]:=3+x
In all cases f[a]
would yield 3+a
. Similarly, f[a]
is equivalent to f@@{a}
.
I have mainly two questions:
- What is the right term to call the shorter version, i.e. the version where one uses
@@
,#
,&
etc.? - When should I prefer the one method and not the other? It seems like many answers given around MA.SE uses the "shorter version". What are the advantages and disadvantages...
Bonus question: Note my first question. I hope I could get more fishing rods and less fish. In other words, what is the official term for these two notions? Where are can I find documentation of these differences? The examples I presented in the this questions are merely examples, and I try to understand where can I rigorously study these notions and similar ones.
OwnValues
. But I think, this observation actually does not clarify matters - the fact that the function in the first 3 cases is stored in a variable is of secondary significance, sinceFunction
-s can be also used directly without being stored anywhere. $\endgroup$@@
) is often just used when it is convenient. For example if you first generate a list using Table and then want the elements of that list to be arguments of your function. Like inf@@Table[i,{i,3}]
. Also sometimesApply
is used to circumvent attributes likeHoldAll
. For example you can writeHold@@{1+2}
, which evaluates toHold[3]
, which is not the same asHold[1+2]
which just evaluates to itself. Some part of your question seems to be about notation, as two lines of code you suggest have the sameFullForm
. Ah there is too much to this question I can't make a point :P $\endgroup$