Re: easier method for Flatten[Position[list2,x_x...??
- To: mathgroup at smc.vnet.net
- Subject: [mg94023] Re: easier method for Flatten[Position[list2,x_x...??
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 2 Dec 2008 00:42:26 -0500 (EST)
- Organization: Uni Leipzig
- References: <gh0jlg$5mu$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, list1 = {a, b, b, e}; list2 = {{a, aP}, {b, bP}, {c, cP}, {d, dP}, {e, eP}, {f, fP}}; list1 /. Rule @@@ Select[list2, MemberQ[list1, First[#]] &] ?? Regards Jens Van Der Burgt, Maarten wrote: > Dear all, > > Below I have two lists. > > The elements x in list1 all appear again in the 2nd level of list2 > together with an associated parameter xP. > > I want to extract the xP as illustrated below. > > I have the feeling it can be done in an easier way. > > > > Does anyone have an idea how? > > > > Thanks for your help, > > > > Maarten > > > > > > list1={a,b,b,e}; > > > > list2={{a,aP},{b,bP},{c,cP},{d,dP},{e,eP},{f,fP}}; > > > > > > pos = Flatten[Position[list2,x_List/;x[[1]]==#]&/@list1]; > > > > list2[[pos,2]] > > > > Out-> {aP,bP,bP,eP} > >
- Follow-Ups:
- Re: Re: Re: easier method for
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: easier method for Flatten[Position[list2,x_x...??
- From: "sjoerd.c.devries@gmail.com" <sjoerd.c.devries@gmail.com>
- Re: Re: easier method for Flatten[Position[list2,x_x...??
- From: Lou Talman <talmanl@mscd.edu>
- Re: Re: Re: easier method for