PRODUCTS
PURCHASE
FOR USERS
COMPANY
OUR SITES
DOCUMENTATION CENTER SEARCH
Mathematica
>
Attributes
>
Built-in
Mathematica
Symbol
Flat and Orderless Functions
Attributes
Patterns and Transformation Rules
Tutorials »
|
Orderless
OneIdentity
See Also »
|
Attributes
Patterns
Defining Variables and Functions
More About »
Flat
Flat
is 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.
MORE INFORMATION
Flat
corresponds to the mathematical property of associativity.
For a symbol
f
with attribute
Flat
,
f
[
f
[
a
,
b
],
f
[
c
]]
is automatically reduced to
f
[
a
,
b
,
c
]
.
Functions like
Plus
,
Times
and
Dot
are
Flat
.
For a
Flat
function
f
, the variables
x
and
y
in the pattern
f
[x_, y_]
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
.
EXAMPLES
CLOSE ALL
Basic Examples
(2)
Nested expressions with flat functions are flattened out:
In[1]:=
In[2]:=
Out[2]=
Flat
implements the notion of associativity:
In[1]:=
Out[1]=
In[2]:=
Out[2]=
Scope
(3)
Properties & Relations
(2)
Possible Issues
(2)
SEE ALSO
Orderless
OneIdentity
TUTORIALS
Flat and Orderless Functions
Attributes
Patterns and Transformation Rules
MORE ABOUT
Attributes
Patterns
Defining Variables and Functions
RELATED LINKS
NKS|Online
(
A New Kind of Science
)
New in 1
© 2008 Wolfram Research, Inc.