# Function with variable arguments [duplicate]

I wrote a function with three arguments like this

f[a_,b_,c_]:=...


When I call this function MMA requires the input of all three arguments (e.g. f[1,2,3]).

Is there a possibility to define the argument c_ as "varaible" that I can call the function with two (e.g. f[1,2]) or three (e.g. f[1,2,3] arguments?

• See here and note that the lhs of := is really just a pattern and you can have "definitions" for as many patterns as you like. f[1]=2; f[a_,b_]=3; f[x_,y_,z_]:=x – Szabolcs Mar 29 '15 at 16:11
• You can also define a default value for c. For example, f[a_, b_, c_:3] := {a, b, c}. Then f[1, 2, 42] gives {1, 2, 42} and f[1, 2] gives {1, 2, 3}. – m_goldberg Mar 29 '15 at 16:25