MathGroup Archive 2006

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

Search the Archive

Re: List Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67939] Re: List Question
  • From: "James Gilmore" <james.gilmore at yale.edu>
  • Date: Thu, 13 Jul 2006 06:54:07 -0400 (EDT)
  • Organization: Yale University
  • References: <e92e03$ljm$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Simon,

One can either use Take[] or write out the operation explicitly:

In[1]:=
list23 = {{x1, y1}, {x2, y2}, {x3, y3, z3}, {x4, y4}};
Map[{#1[[1]], #1[[2]]} &, list23]
Map[Take[#, 2] &, list23]
Out[2]=
{{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}
Out[3]=
{{x1, y1}, {x2, y2}, {x3, y3}, {x4, y4}}

Writing out the operation is advantageous if you want to manipulate the data 
set at the same time e.g. y->y^2, etc.

Cheers
James Gilmore

"Simon Bale" <simonjbale at gmail.com> wrote in message 
news:e92e03$ljm$1 at smc.vnet.net...
> 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.
> 



  • Prev by Date: How to show multiple connections?
  • Next by Date: Re: Use color with ListPlot?
  • Previous by thread: Re: List Question
  • Next by thread: Re: List Question