MathGroup Archive 2000

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

Search the Archive

RE: Newbie question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25300] RE: [mg25275] Newbie question
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 19 Sep 2000 03:45:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Jose,

data = Table[{x[i], y[i]}, {i, 5}]
{{x[1], y[1]}, {x[2], y[2]}, {x[3], y[3]}, {x[4], y[4]}, {x[5], y[5]}}

Here is a pure function which calculates the form you want on a pair of
arguments.

{#1, 1/#2} &[x, y]
{x, 1/y}

But you have to Apply it to a list of two values.

{#1, 1/#2} & @@ {x, y}
{x, 1/y}

So we make an extended pure function which maps the above onto your data
list.

{#1, 1/#2} & @@ # & /@ data
{{x[1], 1/y[1]}, {x[2], 1/y[2]}, {x[3], 1/y[3]},
  {x[4], 1/y[4]}, {x[5], 1/y[5]}}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/




> -----Original Message-----
> From: Jose M Lasso [mailto:jml at accessinter.net]
To: mathgroup at smc.vnet.net
> Hi Mathgroup,
>
> I have some numerical data: data:={{x,y},{x1,y1},{x2,y2}....{xn,yn}},
> I want to transform the data like this:
> data1:={{x,1/y},{x1,1/y1},{x2,1/y2}....{xn,1/yn}}, how can I do this
> transformation? Thanx in advance. Regards
>
> Jose M Lasso



  • Prev by Date: Noise Sphere
  • Next by Date: Q: How to avoid WriteBinary to write an extra nul after each call ?
  • Previous by thread: Re: Newbie question
  • Next by thread: Re: Newbie question