Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Attributes  /
Orderless

  • Orderless is an attribute that can be assigned to a symbol f to indicate that the elements in expressions of the form f [ , , ... ] should automatically be sorted into canonical order. This property is accounted for in pattern matching.
  • The Orderless attribute for a function corresponds to the mathematical property of commutativity.
  • Functions with the Orderless attribute use canonical order as described in the notes for Sort.
  • For an object that represents a matrix or a tensor, the Orderless attribute represents symmetry among indices.
  • Functions like Plus and Times are Orderless.
  • In matching patterns with Orderless functions, all possible orders of arguments are tried.
  • The Orderless attribute must be assigned before defining any values for an Orderless function.
  • See the Mathematica book: Section 2.3.7Section 2.5.3.
  • See also: Sort, Flat, OneIdentity.

    Further Examples

    Functions without the Orderless attribute are not rearranged into a canonical order; with it, they are.

    In[1]:=

    Out[1]=

    In[2]:=

    In[3]:=

    Out[3]=

    In[4]:=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.