While looking for an answer to a different problem, I came across the following example:

In[1]:= Array[Plus[##] &, {2,2}] 
Out[1]= {{2,3},{3,4}}

Having read through the documentation on Slot and SlotSequence, I understand the above example. If we think of it as a matrix $M_{ij}$, it takes the two indices and adds them up, $M_{ij}=i+j$. I also understand that it is equivalent to Array[Plus[#1,#2] &, {2, 2}].

I tried making the expression slightly more complicated:

In[2]:= Array[Plus[##,#] &, {2,2}] 
Out[2]= {{3,4},{5,6}}

which acts as $M_{ij}=(i+j)+i$, or if we replace the last # with #2, $M_{ij}=(i+j)+j$.

Now, I am really stuck on interpreting:

In[3]:= Array[Plus[## #] &, {2,2}]
Out[3]= {{1,2},{4,8}}

What is the corresponding expression for $M_{ij}$?

New contributor
Jakub Kryś is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    FullForm[## #] – Kuba Dec 7 at 13:30
  • Thank you, as a beginner in Mathematica, I don't use FullForm as often as I should... – Jakub Kryś Dec 7 at 14:02
  • 1
    Hmm, I think I need to find a place to use ######& in my code. (It's perhaps less obvious what this is here than in the frontend...) – Brett Champion Dec 7 at 14:42
up vote 11 down vote accepted

Plus[## #] & is the same as Plus[Times[##, #1]], which always computes to the same as the simpler Times[##, #1] (because Plus[x] is just x).

Thus this computes the same as

Table[i^2 * j, {i, 2}, {j, 2}]

Your Answer

Jakub Kryś is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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