16
$\begingroup$

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}?

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!

$\endgroup$
4
  • 4
    $\begingroup$ Is there a way to automatically view the minimum You might be able to parse it out from the output of Information[functionName], It will list all the different signatures of the function there, one per line. $\endgroup$
    – Nasser
    Commented Sep 11, 2018 at 21:31
  • $\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
    Commented Sep 11, 2018 at 21:55
  • 2
    $\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$
    – Greg Hurst
    Commented Sep 12, 2018 at 12:47
  • $\begingroup$ Great, thanks! I hadn't known that was possible $\endgroup$
    – Jmeeks29ig
    Commented Sep 12, 2018 at 19:56

1 Answer 1

18
$\begingroup$

You can use SyntaxInformation:

SyntaxInformation /@ {Sin, Replace} // Column

enter image description here

$\endgroup$
2
  • $\begingroup$ It works - thanks!!! $\endgroup$
    – Jmeeks29ig
    Commented Sep 11, 2018 at 22:48
  • 1
    $\begingroup$ @Jmeeks29ig, you are most welcome. $\endgroup$
    – kglr
    Commented Sep 11, 2018 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.