Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

One wish take easy advantage of the packages/codes buildt through our engagement with mathematica.

Through building packages I see that I have made several functions which are simple and closely related. However, I would prefer one function with several options instead of many simple.

I therefore wish to make a collection of ideas and examples, could be your own code, code located on this page or any other that show good practice of adding options to functions. Efficient smart/neat solutions that can be extended to arbitrarily large functions is appreciated.

It is also easier to remember how to use the custom functions if they reassemble built in functions.I wish to provide an example Stefans answere of how an expansion where you can query certain properties using a string, very similar to LinearModelFit, even though I would assume that the code behind is very very different.

Hopefully answer to this question would help the reader get an idea of how one can expand and add functionality to one function in a good way. I sure know that good examples definitely would help me.

I would like to point out that any change/edit of the question that would increase its usefulness is appreciated!

share|improve this question

closed as off-topic by Michael E2, RunnyKine, ciao, Verbeia May 21 '14 at 3:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, RunnyKine, ciao, Verbeia
If this question can be reworded to fit the rules in the help center, please edit the question.

This is your friend in such situations. –  Sektor May 20 '14 at 18:38
@Sektor What can I do if I want my option to call different functions? –  ALEXANDER May 20 '14 at 22:55
What do you mean by "my option to call different functions" ? I thought you are calling different functions inside a main one and passing optional arguments to them, or am I mistaken ? –  Sektor May 20 '14 at 23:08
No sorry, that is correct. Im just struggling with seeing how to have a main function that when given different options chooses complete different functions inside to be executed. –  ALEXANDER May 20 '14 at 23:22
By coincidence, an answer I gave today to another question contains an example of the kind of option processing you are asking about. I don't know that you find it useful because it was chosen to illustrate a somewhat different than one you bring up. But you might look at it and, perhaps, get some ideas from it. –  m_goldberg May 20 '14 at 23:32

Browse other questions tagged or ask your own question.