Timeline for Function with variable arguments [duplicate]
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 29, 2015 at 16:30 | history | closed | Kuba Szabolcs m_goldberg Sjoerd C. de Vries Mr.Wizard | Duplicate of Can a function be made to accept a variable amount of inputs? | |
| Mar 29, 2015 at 16:27 | review | Close votes | |||
| Mar 29, 2015 at 16:32 | |||||
| Mar 29, 2015 at 16:25 | comment | added | m_goldberg | 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}. | |
| Mar 29, 2015 at 16:11 | comment | added | Szabolcs | 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 | |
| Mar 29, 2015 at 16:09 | history | asked | Phadreus | CC BY-SA 3.0 |