Re: Position on a List
- To: mathgroup at smc.vnet.net
- Subject: [mg13188] Re: Position on a List
- From: "Allan Hayes" <hay at haystack.demon.cc.uk>
- Date: Mon, 13 Jul 1998 07:42:37 -0400
- References: <6mqa63$2qt@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Idoia Aguirre wrote:
|
| When I do: Position[{1/A, A}, A] | | I obtain: {{1,1},{2}}
|
| But I would like to obtain only : {{2}} |
Several correspondents have pointed out that specifying the level does
the trick:
Position[{1/A, A}, A, {1}]
{{2}}
Position has two other controls that are often useful:
1) the maximum number of positions to return:
Position[{1/A, A, A, A}, A, {1}]
{{2}, {3}, {4}}
Position[{1/A, A, A, A}, A, {1},2]
{{2}, {3}}
2) Whether to look inside heads:
Position[A[1/A, A, A],A, {1}]
{{0}, {2}, {3}}
Position[A[1/A, A, A],A, {1}, Heads->False]
{{2}, {3}}
Using all possibilites give us three optiona controls:
Position[expression,
level specification (default {0,Infinity}),
maxnumber of positions to return (default Infinity),
Heads->True (default) or Heads-> False ]
------------------------------------------------------------- Allan
Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642