I tried to join a series of evaluations with nested slots as follows:
#^2 & /@ #^2 & /@ Range[10]
However, the results were somewhat different from what I expected...
{1, 4, 9, 16, 25, 36, 49, 64, 81, 100}
The following code gave me the expected results:
#^2 & /@ (#^2 & /@ Range[10])
as
{1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000}
I assumed that nested slots would be evaluated from the outside. Do we have to use ugly parentheses in this case? Is there any smart way to handle a series of evaluations with slots?
Function (&)
binds more thanMap (/@)
. You can check out a symbol's precedence using the functionPrecedence
. $\endgroup$Range[10]^2^2
orRange[10]^4
$\endgroup$Composition[#^2 &, #^2 &] /@ Range[10]
$\endgroup$f/@2
does not produce errors. $\endgroup$Precedence
is useless in general, as shown in my naive answer in the linked topic :) $\endgroup$