Re: List Question
- To: mathgroup at smc.vnet.net
- Subject: [mg67955] Re: List Question
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 13 Jul 2006 06:55:42 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <e92e03$ljm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Simon Bale wrote: > Hi, > > I have a list with the following structure: > > {{x1,y1},{x2,y2},{x3,y3,z3},{x4,y4}...} > > As you can see some of the data points have three elements. I would > like to remove these z elements so that the list has a structure > {{x1,y1},{x2,y2},{x3,y3},{x4,y4}...}. I'm not sure how to achieve this > so any > help is greatly appreciated. > > Regards, Simon Bale. > Hi Simon, A transformation rule [1] will do it. For instance {{x1, y1}, {x2, y2}, {x3, y3, z3}, {x4, y4}} /. {a_, b_, c_} :> {a, b} returns {{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}} Best regards, Jean-Marc [1] "Transformation Rules and Definitions", _The Mathematica Book Online_, http://documents.wolfram.com/mathematica/book/section-2.5