Clear, ClearAll, Remove

Mathematica has several places where it stores defintions, and I discuss this subject in another section.  Clear, ClearAll, and Remove are used to erase previous definitions.

The following clears symbols (f, h, g).

The following claers all symbols matching character strings "MakeGraph*" and "MakeCurve*"

The following clears all symbols in the Global context.

In each example above we could have used ClearAll or Remove and got similar results.

Clear[f]

Clear[f] clears all definitions associated with (f) except for:
(1)  Attributes of (f)
(2)  DefaultValues for (f)
(3)  Options[f]
(4)  Messages associated with (f)

Also:
(1)  The Symbol (f) remains on the list of symbols in the appropriate context after evaluating Clear[f].
(2)  Assingments to In, and Out which are normally accessed using %,  %8, etc are not affected by evaluating Clear[f].
(3)  Assignments such as  ,  and   are not affected by evaluating  Clear[f].

I have done experiments to check everything I can think of and all other definitions associated with (f) are erased by Clear[f].  In particular erases , , , , , and .

ClearAll[f]

ClearAll[f] clears all definitions associated with (f):
However, after evaluating  ClearAll[f]
(1)  The Symbol (f) remains on the list of symbols in the appropriate context after evaluating ClearAll[f].
(2)  Assingments to In, and Out which are normally accessed using %,  %8, etc are not affected by evaluating ClearAll[f].
(3)  Assignments such as  ,  and   are not affected by evaluating  ClearAll[f].

Specifically  ClearAll[f]  erases  , , , , , , , , and
Messages associated with (f).

Remove[f]

For all practical purposes Remove[f]  deletes any previous use of the symbol (f) from the Mathematica session.
Specifically Remove[f] does the following:
(1)  Clears all definitions associated with (f).
(2)  The symbol (f) is removed from the list of symbols in the appropriate context.
(2)  For all practical purposes assingments such as  ,     are erased.

This includes assingments to the In, and Out history which are normally accessed using %,  %8, etc.
Such assignments aren't actually erased.  Instead the symbol (f) in such assingments is changed to  Removed["f"].

Created by Mathematica  (May 16, 2004)

Back to Ted’s Tricks index page