In order to create a function that would add any number of arguments, I tried
f[_]=Plus f[1,2,3]
and the output was f[1,2,3] instead of 6. I thought this had worked for me before... what should I do instead?
That's exactly what I ended up trying. Before, I kept trying to use conditions that weren't necessary; thanks for your help.
try:
ClearAll[MyPlus] MyPlus[x___Integer] := Plus[x] MyPlus[1] MyPlus[1, 2, 3] MyPlus[]
The ClearAll is not necessary, I'm just being careful ;)
How would I set conditions for it to be only for integers? I tried IntegerQ, but I'm unsure of the format. I tried using IntegerQ, but I'm unsure how to format it. Thank you for answering my beginner's question. I appreciate it.
In[1]:= f = Plus
Out[1]= Plus
In[2]:= f[1, 2, 3]
Out[2]= 6