The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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, 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

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

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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.