Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Clear all variables but not functions
Posted:
Oct 20, 2011 6:55 AM


On 10/19/11 at 5:34 AM, mailcwc@gmail.com wrote:
>I define some functions in the init.m that starts with Mathematica. >How do I clear all variables but not these functions in the init.m?
>I am also confused about the differences among Remove, Clear, >ClearAll, and Quit. Are there some cases that one function is >preferred than others.
Clear[f] would clear any definitions and values assigned to f but would not clear any defaults, options or attributes assigned to f.
ClearAll[f] clears options, defaults and attributes assigned to f as well as values and definitions.
Neither Clear nor ClearAll actually remove the things cleared. That is, if you do
f[x_]:=2 x Clear[f] ?Global`*
You will see f is still one of the symbols in the Global context.
Remove[f] actually removes f. That is do
f[x_]:=2 x Remove[f] ?Global`*
and f will not be found in the Global context
Quit quits the kernel. This will remove all symbols, reset the In/Out stack etc. Basically, all evaluation that Mathematica does ends when you Quit.
And since none of these do exactly the same thing, there will be times when one is preferred over the others.



