# How &@ and &/@works?

I have the following expression:

(Join[#, Reverse[#, {2}]] &@Partition[#, 2, 1, 1]) & /@ Vec

(* where: *)
Vec={{2,0},{1,1},{0,2}},


but I am not sure how this expression works. I tried

Partition[#, 2, 1, 1]) & /@ Vec,{0,2}}


and

Partition[Vec, 2, 1, 1])


but they gave me different results. I am not sure what # in the Join[] stands for (Partition[] or Vec).

In general, what is the logic behind this expression?

• – Sjoerd Smit Oct 27 '20 at 15:42

## 1 Answer

Due to the precedence of nested anonymous functions, the innermost expression:

Join[#, Reverse[#, {2}]] &


Is essentially identical to:

Function[{x}, Join[x, Reverse[x, {2}]]


Let's explicitly label this as function f using (yet another mostly equivalent notation):

f[x_] := Join[x, Reverse[x, {2}]]


So we can rewrite the original expression as:

(f@Partition[#, 2, 1, 1]) & /@ Vec


We can again rewrite the anonymous function, let's call it g this time:

g[x_] := f@Partition[x, 2, 1, 1]


(Or, equivalently: f[Partition[x, 2, 1, 1], rewriting the @ in perhaps more familiar terms.)

Then the expression becomes:

g /@ Vec


Which is exactly equivalent to: Map[g, Vec].