Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Clear all variables but not functions
Replies: 1   Last Post: Oct 20, 2011 6:55 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bill Rowe

Posts: 1,647
Registered: 3/14/08
Re: Clear all variables but not functions
Posted: Oct 20, 2011 6:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.