Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

14
  • 5
    $\begingroup$ For built in functions you can use SyntaxInformation. For example SyntaxInformation[Mod] returns {"ArgumentsPattern" -> {_, _, _.}} indicating 3 arguments of which the last one is optional. $\endgroup$ Commented Jun 19, 2012 at 14:33
  • 3
    $\begingroup$ What should it return for foo[x__Integer] := {x}? And what for bar[x_] := 1; bar[x_, y_, z_] := 2? Should it also consider UpValues like f[g,g] ^= 0? And would a[x_, {y_, z_}] := x+y/z count as taking two or three arguments? $\endgroup$ Commented Jun 19, 2012 at 14:39
  • 1
    $\begingroup$ This becomes challenging, output for the following cases ? f[x_]:=1,f[x_,y_]:=1,f[x_,OptionsPattern[]] $\endgroup$ Commented Jun 19, 2012 at 14:52
  • $\begingroup$ Then there are things like p[n_][x_] := (* stuff *)... $\endgroup$ Commented Jun 19, 2012 at 15:03
  • $\begingroup$ @imnage_doctor In order I would say: - {1,0} - {2,0} - {1+n,n} assuming that OptionsPattern takes up to n optional values $\endgroup$ Commented Jun 19, 2012 at 15:04