Re: newbie list question
- To: mathgroup at smc.vnet.net
- Subject: [mg114992] Re: newbie list question
- From: Thomas Dowling <thomasgdowling at gmail.com>
- Date: Tue, 28 Dec 2010 06:47:04 -0500 (EST)
Hello,
listA = {4, 5, 8, 2, 6, 4};
listB = {8, 4, 2};
Flatten@Map[Position[listA, #, 1, 1] & , listB]
Compare with:
Flatten@Map[Position[listA, #, 1] & , listB]
(?and with
Flatten@Position[listA, Alternatives @@ listB]
)
Good luck
Tom Dowling
On Sun, Dec 26, 2010 at 9:02 AM, Gareth Edwards <
gareth.edwards at cubicmotion.com> wrote:
> 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!
>
>