This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Assignments  /
Clear

  • Clear[ , , ... ] clears values and definitions for the .
  • Clear[" ", " ", ... ] clears values and definitions for all symbols whose names match any of the string patterns .
  • Clear does not clear attributes, messages, or defaults associated with symbols.
  • Clear[" form "] allows metacharacters such as *, as specified in Section¬†A.3.13.
  • Clear[" context `*"] clears all symbols in a particular context.
  • Clear is HoldAll.
  • Clear does not affect symbols with the attribute Protected.
  • See the Mathematica book: Section 1.2.2, Section 1.7.1, Section 2.4.3, Section 2.6.12,¬†Section A.5.4.
  • See also: Remove.

    Further Examples

    Various rules and values are associated with h1.

    In[1]:=

    In[2]:=

    Out[2]=

    In[3]:=

    Here are the rules in action.

    In[4]:=

    Out[4]=

    Clear gets rid of values and definitions from h1.

    In[5]:=

    The Listable attribute is left alone by Clear.
    To get rid of values alone use Unset; to get rid of everything use ClearAll; to get rid of everything including the symbol h1 itself use Remove.

    In[6]:=

    Out[6]=