How can I view the minimal required arguments of a Wolfram Language function?
How can I view the minimal required arguments of a Wolfram Language function?
This question might be a bit of an overstretch, or really obvious, but I haven't been able to find an answer yet.
Is there a way to automatically view the minimum required arguments for a WL function? For example, Sin
only requires 1 argument, while Replace
requires both an expression and the list of rules. Is there a way that, for example, I can input Sin
into a function, and get back something like Real
, or enter Replace
, and get back Expression, Rules
?
Sin
Replace
Sin
Real
Replace
Expression, Rules
I hope this makes sense - I would like to be able to automate input to any function in Mathematica, by being given the required arguments.
Thanks!
Is there a way to automatically view the minimum
Information[functionName]
$begingroup$
That's a good idea, however, when I try val = Information[Replace], and then view the results with ?val, it returns that val = Null
$endgroup$
– Jmeeks29ig
Sep 11 '18 at 21:55
$begingroup$
@Jmeeks29ig
Information
has side effects and doesn't return anything. Fortunately we can scrape the side effects with Block[CellPrint = Sow, Reap[Information[Replace]][[-1, 1]]]
. However Replace::usage
would be an easier way to see the information your after.$endgroup$
– Chip Hurst
Sep 12 '18 at 12:47
Information
Block[CellPrint = Sow, Reap[Information[Replace]][[-1, 1]]]
Replace::usage
$begingroup$
Great, thanks! I hadn't known that was possible
$endgroup$
– Jmeeks29ig
Sep 12 '18 at 19:56
1 Answer
1
You can use SyntaxInformation
:
SyntaxInformation
SyntaxInformation /@ Sin, Replace // Column
$begingroup$
It works - thanks!!!
$endgroup$
– Jmeeks29ig
Sep 11 '18 at 22:48
$begingroup$
@Jmeeks29ig, you are most welcome.
$endgroup$
– kglr
Sep 11 '18 at 22:56
Thanks for contributing an answer to Mathematica Stack Exchange!
But avoid …
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
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.
$begingroup$
Is there a way to automatically view the minimum
You might be able to parse it out from the output ofInformation[functionName]
, It will list all the different signatures of the function there, one per line.$endgroup$
– Nasser
Sep 11 '18 at 21:31