SetAttributes
SetAttributes[symbol,attr]
adds attr to the list of attributes of the symbol symbol.
SetAttributes["symbol",attr]
adds attr to the attributes of the symbol named "symbol" if it exists.
SetAttributes[s,{attr1,attr2,…}]
sets several attributes at a time.
SetAttributes[{s1,s2,…},attrs]
sets attributes of several symbols at a time.
Details
- SetAttributes modifies Attributes[s].
- SetAttributes has attribute HoldFirst.
- SetAttributes does not affect symbols with the attribute Locked.
Examples
open allclose allScope (3)
Properties & Relations (6)
Set a single attribute for the symbols f and g:
SetAttributes adds to the already existing attributes; Attributes[g]={..} resets the list:
SetAttributes is equivalent to this assignment to the attributes:
Use ClearAttributes to clear a particular attribute:
Protecting a symbol is equivalent to setting the Protected attribute:
You can still change the attributes of a protected symbol:
After setting the attribute Locked, no more changes to the attributes can be made:
A locked symbol can no longer be unprotected, as the Protected attribute cannot be cleared:
SetAttributes has the attribute HoldFirst:
Text
Wolfram Research (1988), SetAttributes, Wolfram Language function, https://reference.wolfram.com/language/ref/SetAttributes.html.
CMS
Wolfram Language. 1988. "SetAttributes." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SetAttributes.html.
APA
Wolfram Language. (1988). SetAttributes. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SetAttributes.html