Remove

Remove[symbol1,]

removes symbols completely, so that their names are no longer recognized by the Wolfram Language.

Remove["form1","form2",]

removes all symbols whose names match any of the string patterns formi.

Details

  • You can use Remove to get rid of symbols that you do not need, and which may shadow symbols in contexts later on your context path.
  • Remove["form"] allows the following metacharacters:
  • *match zero or more characters
    @match one or more characters, but not uppercase letters
  • Remove["context`*"] removes all symbols in a particular context.
  • Remove is HoldAll.
  • Remove does not affect symbols with the attribute Protected.
  • Once you have removed a symbol, you will never be able to refer to it again, unless you recreate it.
  • If you have an expression that contains a symbol that you remove, the removed symbol will be printed as Removed["name"], where its name is given in a string.
  • Remove works with LocalSymbol, CloudSymbol, PersistentValue and InitializationValue objects.

Examples

open allclose all

Basic Examples  (1)

Scope  (2)

Remove a local symbol:

Remove a persistent value:

Generalizations & Extensions  (2)

Remove all symbols in a given context:

Specify symbols to remove as string patterns:

Applications  (1)

If a symbol from a package is used before the package is loaded, an extra symbol is created:

The extra symbol should be removed:

Only the correct symbol from the package remains:

Properties & Relations  (3)

If a symbol is removed, all of its properties and definitions are removed as well:

Using the same symbol again creates a new one without any of its old properties:

ClearAll also removes all properties and definitions but leaves the symbol intact:

If an expression still refers to a removed symbol, those places are denoted with Removed:

Possible Issues  (1)

Protected symbols cannot be removed:

Use Unprotect to remove protected symbols:

Wolfram Research (1988), Remove, Wolfram Language function, https://reference.wolfram.com/language/ref/Remove.html (updated 2016).

Text

Wolfram Research (1988), Remove, Wolfram Language function, https://reference.wolfram.com/language/ref/Remove.html (updated 2016).

BibTeX

@misc{reference.wolfram_2020_remove, author="Wolfram Research", title="{Remove}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/Remove.html}", note=[Accessed: 10-April-2021 ]}

BibLaTeX

@online{reference.wolfram_2020_remove, organization={Wolfram Research}, title={Remove}, year={2016}, url={https://reference.wolfram.com/language/ref/Remove.html}, note=[Accessed: 10-April-2021 ]}

CMS

Wolfram Language. 1988. "Remove." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/Remove.html.

APA

Wolfram Language. (1988). Remove. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Remove.html