| |
4.8 Larger functions, local variables and the code modularization
In the majority of real situations, the code for a typical function is longer than one or two lines (in other words, not every problem can be solved by one - liners). Also, it is often convenient to introduce intermediate variables, both to avoid redundant computations and to improve the code readability. Such variables one has to localize, in order to avoid name conflicts with the global variables already defined in the system, and in general not to "pollute" the global name space. On the scale of a single function or program, there are 3 constructs in Mathematica which provide this functionality: Module, Block and With. These constructs are explained in detail in Mathematica Book and Mathematica Help, so I will say just a few words about them here. On the larger scale, this is supported through the system of packages - we will consider them in part II.
|