MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: List Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67961] Re: [mg67889] List Question
  • From: gardyloo <gardyloo at mail.wsu.edu>
  • Date: Thu, 13 Jul 2006 06:56:43 -0400 (EDT)
  • References: <200607120905.FAA22137@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, Simon,

    I'd guess one of the easier ways is just to do a substitution which
will just replace each three-element sublist with the first two of its
elements:

In[370]:=
l1 = {{x1, y1}, {x2, y2}, {x3, y3, z3}, {x4, y4}}

Out[370]=
{{x1, y1}, {x2, y2}, {x3, y3, z3}, {x4, y4}}

In[371]:=
l1 /. {{a_, b_, c_} -> {a, b}}

Out[371]=
{{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}

            Hope that helps!
                      Curtis O.


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.
>
>
>   

-- 
==========================================================
Curtis Osterhoudt          
gardyloo at mail.remove_this.wsu.and_this.edu
PGP Key ID: 0x088E6D7A
Please avoid sending me Word or PowerPoint attachments
See http://www.gnu.org/philosophy/no-word-attachments.html
==========================================================



  • References:
  • Prev by Date: Re: Use color with ListPlot?
  • Next by Date: RE: Use color with ListPlot?
  • Previous by thread: Re: List Question
  • Next by thread: Re: List Question