Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Defining Variables and Functions > Attributes > Orderless >

Orderless

Orderless
is an attribute that can be assigned to a symbol f to indicate that the elements in expressions of the form 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.
  • 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.
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
 
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
All possible argument orderings are tried to match a definition for an orderless function:
Elements of an expression whose head is orderless are sorted into standard order:
Pattern matching with orderless functions can lead to a large number of possible cases:
New in 1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF