"logo.gif"  
Main
Read Online
Download PDF
Additional resources
Revision history
Known typos/bugs
Report a bug
License terms
About the author
"node172_1.gif" "node172_2.gif" "node172_3.gif"

4.4.6    Assigning values to function symbols (names)

Since function symbols are just normal symbols, they can be used as variables and in particular can be assigned values. When the function is called on some argument, these values are computed before any other computation takes place. Consider an example:

"node172_4.gif"

"node172_5.gif"

Notice that this does not mean that the previous rule for < f > disappeared - it is still in the rule base, as can be checked with DownValues :

"node172_6.gif"

"node172_7.gif"

It is just that < f > now has also OwnValue < Sin >, which is computed in this case before any arguments are considered, and then the DownValue rule has no chance to apply :

"node172_8.gif"

"node172_9.gif"

We can see what happens, with the help of the Trace command :

"node172_10.gif"

"node172_11.gif"

To "restore" the function in this case, we obviously can  not use Clear, since then also the DownValues of < f > will be cleared. In such a case, use Unset (section 2.2.6) :

"node172_12.gif"

"node172_13.gif"

In general, the above behavior means  that one has to be careful and make sure that the symbol which is going to be used as a function name, does not have an OwnValue (unless this is what is desired, which is a rare case) - otherwise the newly defined function will not work properly.

"node172_14.gif" "node172_15.gif" "node172_16.gif"

Created by Wolfram Mathematica 6.0  (05 February 2009) Valid XHTML 1.1!