Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain

• To: mathgroup at smc.vnet.net
• Subject: [mg24177] Re: Need to reduce 2 lists so that only {x,y} pairs with same x remain
• From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
• Date: Wed, 28 Jun 2000 22:50:58 -0400 (EDT)
• Organization: Universitaet Leipzig
• References: <8jc73k\$dg3@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```materialsscientist at my-deja.com wrote:
>
Hi,

the function

PairSelect[data1_, data2_] := Module[{lst},
lst = Intersection @@ Map[First , {data1, data2}, {2}];
Select[#, MemberQ[lst, First[#]] &] & /@ {data1, data2}
]

return a list of {data1,data2} with common x values of both
lists.

Regards
Jens

> Hello,
>
> I have 2 lists of data:
>
> for example
> data1={{1,1},{1.5,1.5},{2,2},{3,3},{4,4},{5,5}}
>
> data2={{1,2},{2,3},{3,4},{4,5},{6,7},{7,8}}
>
> I want to do a point by point comparision, so I
> need to reduce both data1 and data2 so that
> common x data in the {x,y} pairs for each list
> remain.
>
> Thus the lists should look like this:
>
> data1={{1,1},{2,2},{3,3},{4,4}}
> data2={{1,2},{2,3},{3,4},{4,5}}
>
> What function(s) would to something like this?
>
> Thanks,
>
> Chuck
>
> Sent via Deja.com http://www.deja.com/