MathGroup Archive 2010

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

Search the Archive

Re: newbie list question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115017] Re: newbie list question
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Tue, 28 Dec 2010 06:51:39 -0500 (EST)
  • References: <if70bt$330$1@smc.vnet.net>

In[5]:=  listA = { 4, 5, 8, 2, 6, 4 }

Out[5]= {4, 5, 8, 2, 6, 4}

In[6]:=  listB = { 8, 4, 2 }

Out[6]= {8, 4, 2}

In[7]:= First[Position[listA, #]] & /@ listB

Out[7]= {{3}, {1}, {4}}

--David
http://Scientificarts.com/worklife

On Dec 26, 4:02 am, Gareth Edwards <gareth.edwa... at cubicmotion.com>
wrote:
> Hi,
>
> Liking Mathematica a lot, but struggling with the early part of the learn=
ing curve, i.e. don't know what I don't know...
>
> What would be the neatest syntax for finding the first location of elemen=
ts from one list in another? For example:
>
> listA = { 4,5,8,2,6,4 }
> listB = { 8,4,2 }
>
> I would like a function to return {3,1,4} in this case (the first locatio=
n in A of each element in B)
>
> Many thanks!



  • Prev by Date: Best Way to Copy from Mathematica to Powerpoint?
  • Next by Date: Re: newbie list question
  • Previous by thread: Re: newbie list question
  • Next by thread: Re: newbie list question