MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Position on a List


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



  • Prev by Date: Re: installing TeXSave math fonts
  • Next by Date: Re: How to see a scanned photo whith Mathematica
  • Previous by thread: Re: 3DGraphics color problem
  • Next by thread: Limit doesn't work properly