Mathematica 9 is now available

Flat

Usage

Flat 是一个属性,它可以赋给一个符号f , 指定涉及嵌套函数 f 的所有表达式应当被压平。这个属性在模式匹配中说明。


Notes

Flat 相应于数学上的结合律。
• 对一个有属性 Flat的符号 f , f[f[a, b], f[c]]自动减小到 f[a, b, c].
• 象Plus, TimesDot函数是 Flat.
• 对一个 Flat 函数,在模式 f[x_, y_]中变量xy相应于任何参数序列。
Flat 属性必须在对Flat函数定义任何值被分配。
• 参见Mathematica 全书: 2.3.7节和 2.5.3节.
• 同时参见: Orderless, OneIdentity.
Further Examples

Clear all of the rules and attributes for a symbol fff.

In[1]:=  

Set the Flat attribute for fff.

In[2]:=  

Inputs with a head of fff will now be flattened automatically over fff.

In[3]:=  

Out[3]=

The Flat attribute also has an effect in pattern matching. This rule applies because of the Flat attribute.

In[4]:=  

Out[4]=

Remove the Flat attribute from fff.

In[5]:=  

Without the Flat attribute, this rule is not used.

In[6]:=  

Out[6]=

Associative operations, such as Plus, have the Flat attribute.

In[7]:=  

Out[7]=

This rule is applied because of the Flat attribute of Plus.

In[8]:=  

Out[8]=

This also works.

In[9]:=  

Out[9]=



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.