Re: newbie list question

*To*: mathgroup at smc.vnet.net*Subject*: [mg114991] Re: newbie list question*From*: Matthias Bode <lvsaba at hotmail.com>*Date*: Tue, 28 Dec 2010 06:46:53 -0500 (EST)

Hola Gareth: Step by step In[1]:== listA == {4, 5, 8, 2, 6, 4}; listB == {8, 4, 2}; listA2 == DeleteDuplicates[listA] listC == Sort[Intersection[listA2, listB], Greater] Flatten[Table[Position[listA2, listC[[n]]], {n, 1, Length[listC]}]] Out[3]== {4, 5, 8, 2, 6} Out[4]== {8, 4, 2} Out[5]== {3, 1, 4} Best regards, MATTHIAS BODE S 17.35775=B0, W 066.14577=B0 > Date: Sun, 26 Dec 2010 04:02:23 -0500 > From: gareth.edwards at cubicmotion.com > Subject: [mg114986] newbie list question > To: mathgroup at smc.vnet.net > > Hi, > > Liking Mathematica a lot, but struggling with the early part of the learning curve, i.e. don't know what I don't know... > > What would be the neatest syntax for finding the first location of elements 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 location in A of each element in B) > > Many thanks! >