Skip to content

ClearAttributes ​

Turns off one of the Wolfram-named properties Attributes can report.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageClearAttributes!
ClearAttributes(f, attr)Turns attrattr off for ff's operator definition, in place.
ClearAttributes(f, {attr1, attr2, ...})Turns off several attributes at once.
Typed signatures
TypePackageApplies
(symbol, any) -> anycombinatoricsalways

Domain: Collections

Details
  • The inverse of SetAttributes, over the same {Flat,HoldAll,Listable,Orderless}\{Flat, HoldAll, Listable, Orderless\}. Declines (stays unevaluated) for an undeclared ff or any other attribute name.
  • A declared head is Protected: ClearAttributes leaves the call unevaluated and says ClearAttributes::write (Tag f in f is Protected.), where Wolfram, whose Protected guards definitions rather than attributes, makes the change.
  • Always returns NothingNothing, like Wolfram's own NullNull.

Examples

Basic #

turn Flat and Orderless on for a head of your own, clear Flat, then read the rest back

live ↗
InLast([userHead(x):−x,SetAttributes(userHead,[Flat,Orderless]),ClearAttributes(userHead,Flat),Attributes(userHead)])\mathrm{Last}(\bigl\lbrack\mathrm{userHead}(x)\coloneq x, \mathrm{SetAttributes}(\mathrm{userHead}, \bigl\lbrack\mathrm{Flat}, \mathrm{Orderless}\bigr\rbrack), \mathrm{ClearAttributes}(\mathrm{userHead}, \mathrm{Flat}), \mathrm{Attributes}(\mathrm{userHead})\bigr\rbrack)Out[Orderless]\bigl\lbrack\mathrm{Orderless}\bigr\rbrack

Wolfram needs no definition before a symbol takes attributes; here the head is defined first, since ClearAttributes leaves an undeclared symbol alone.

a declared head is Protected: the call stays unevaluated and says ClearAttributes::write

live ↗
InClearAttributes(HarmonicMean,Orderless)\mathrm{ClearAttributes}(\mathrm{HarmonicMean}, \mathrm{Orderless})OutClearAttributes(HarmonicMean,Orderless)\mathrm{ClearAttributes}(\mathrm{HarmonicMean}, \mathrm{Orderless})
About
Examples2
Checked againstWolfram Language 1 differ
CrosswalkWolfram Language

See also: Attributes, SetAttributes