This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# Flat

 Flatis an attribute that can be assigned to a symbol f to indicate that all expressions involving nested functions f should be flattened out. This property is accounted for in pattern matching.
• Flat corresponds to the mathematical property of associativity.
• For a symbol f with attribute Flat, is automatically reduced to .
• For a Flat function f, the variables x and y in the pattern can correspond to any sequence of arguments.
• The Flat attribute must be assigned before defining any values for a Flat function.
• When functions that are Flat are used in pattern matching, they often also require the attribute OneIdentity.
Nested expressions with flat functions are flattened out:
Flat implements the notion of associativity:
Nested expressions with flat functions are flattened out:
 Out[2]=

Flat implements the notion of associativity:
 Out[1]=
 Out[2]=
 Scope   (3)
Nested expressions with associative functions are flattened out:
In pattern matching, Flat allows sequences of elements to be replaced:
For flat and orderless functions, any subset of the arguments may match:
Nested expressions with flat functions are automatically flattened:
For flat functions, a definition for the two-argument case is normally sufficient:
Pattern matching for flat functions requires the OneIdentity attribute as well:
For flat and orderless functions, pattern matching may have to try a large number of cases:
Longest can be used to prevent additional matches for shorter subexpressions:
New in 1