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 / Attributes  /
OneIdentity

  • OneIdentity is an attribute that can be assigned to a symbol f to indicate that f [ x ], f [ f [ x ]], etc. are all equivalent to x for the purpose of pattern matching.
  • Functions like Plus and Times have the attribute OneIdentity.
  • The fact that Times has attribute OneIdentity allows a pattern like n_. x_ to match x.
  • See the Mathematica book: Section 2.3.7Section 2.5.3.
  • See also: Flat, Nest.

    Further Examples

    These three functions have the attribute OneIdentity.

    In[1]:=

    Out[1]=

    These three don't.

    In[2]:=

    Out[2]=