next up previous contents
Next: Contexts in Mathematica Up: Appendix II: Intro Previous: Select Mathematica Commands

Appendix III: Packages in Mathematica

Since Mathematica is an interpreted language (each session involves line-by-line processing of user inputs), there is no convenient way to write a ``program'' in Mathematica. Thus, in order to execute complex tasks requiring many lines of input, it is necessary to construct packages to be loaded into Mathematica at the time such tasks are to be done. Packages can be written by anyone; there are several built-in packages that you can load at any time. Sooner or later, though, you will probably want to write your own packages to hold frequently used definitions or to accomplish specific tasks. The idea is to define a function for each task you wish to accomplish and have successive functions call previous ones. In this way, you build step-by-step a complex function which ``acts'' like a program when the package is loaded and the function is executed at the In[]:= line. Both Modules and Packages help the user define "local" and "global" variables to avoid conflicting names used in these various contexts