MathGroup Archive 1999

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

Search the Archive

Re: Combining Lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16753] Re: [mg16722] Combining Lists
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Wed, 24 Mar 1999 02:23:59 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

On Mon, Mar 22, 1999, JOHN C ERB <JOHN_C_ERB at prodigy.net> wrote:

>I have a set of x & y data points in one list;
>
>xydata={{x1,y1},{x2,y2},{x3,y3},{x4,y4}};
>
>and a corresponding set of z data points in another list:
>
>zdata={z1,z2,z3,z4};
>
>I wish to combine them into one list of {x,y,z} data points,
>which I can do by:
>
>{temp1,temp2}=Transpose[xydata];
>xyzdata=Transpose[{temp1,temp2,zdata}]
>
>which gives the desired result:
>
>{{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},{x4,y4,z4}}
>
>QUESTION:  Is there a more efficient way of doing this?
>
>Thank you.
>
>John C. Erb
>
>email: John_C_Erb at prodigy.net

It depends what you mean by "more efficient". Your code is very fast and
in this sense "very efficient" and thus requires no improvement. If you
simply mean something a little "more elegant" (but in this case slower)
here is one possible way:

MapThread[Append,{xydata,zdata}]

Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp/
http://eri2.tuins.ac.jp/



  • Prev by Date: Coefficients in expressions
  • Next by Date: Re: combinations
  • Previous by thread: Combining Lists
  • Next by thread: RE: Combining Lists