MathGroup Archive 2006

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

Search the Archive

Re: building a list provided the position of element is known

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68046] Re: building a list provided the position of element is known
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Fri, 21 Jul 2006 05:37:39 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 7/20/06 at 6:04 AM, Arkadiusz.Majka at telekomunikacja.pl (Arkadiusz
Majka) wrote:

>I have two elements, say A and B and their positions in a three
>dimensional list. Eg {1,3} means that position of A is 1 , position
>ob is 3 and a list is given {A,_,B}. {3,2} corresponds to {_,B,A},
>{3,3} corresponds to {_,_,{A,B}}.

>How can I code it in Mathematica using any number of elements and a
>list of any length>0?

Use Position. From your description above

{Position[list,A][[1,1]],Position[list,B][[1,1]]}

will do what you want. This solution implicitly assumes either A and B only appear once in list or that you are only interested in the first occurrence of A and B
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: MapThread and If
  • Next by Date: Re: MapThread and If
  • Previous by thread: building a list provided the position of element is known
  • Next by thread: Re: building a list provided the position of element is known