Mathematica 9 is now available

Position

Usage

Position[expr, pattern] 给出出现在expr中匹配pattern的对象的位置列表。
Position[expr, pattern, levspec] 仅查找出现在由levspec指定的层的对象。
Position[expr, pattern, levspec, n] 给出找到的前n个对象位置。


Notes

• 例如: Position[ 1+x^2, 5, x^4 , x^_]LongRightArrow .
Position[expr, pattern] 轮流测试expr的所有子部分试图找到匹配pattern的一个对象。
Position 以在Extract, ReplacePartMapAt中适于使用的形式返回一个位置列表。这个形式和在Part中使用的形式不同。
• 对Position的缺省层指定是{0, Infinity},有头Heads -> True
• 一个由Position返回的部分指定{}表示整个expr.
Position[list, pattern,  1 , Heads -> False] 仅查找作为list的完整元素出现的对象位置。
• 层规定在A.3.6节中描述。
• 参见 Mathematica 全书: 1.8.5, 节 2.1.7, 节 2.2.4 and 节 2.3.2.
Further Examples

The symbol c occurs in the third position of this list.

In[1]:=  

Out[1]=

This gives the positions of the elements of the list that are manifestly powers.

In[2]:=  

Out[2]=

The head of the expression (List in position 0) and the first two elements of the expression (a and Pi) have head Symbol.

In[3]:=  

Out[3]=

In[4]:=  

Out[4]=

In[5]:=  



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.