MathGroup Archive 2003

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

Search the Archive

Re: a little more complex list operation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40248] Re: [mg40237] a little more complex list operation
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Fri, 28 Mar 2003 04:28:29 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On Thursday, March 27, 2003, at 06:49 AM, Nathan Moore wrote:

> Thanks very much for all the previous replies.  Another simple 
> question -
> though I guess this will require more complex syntax.  Suppose I have 
> the
> list,
>
> data = {{x1,y1},{x2,y2},{x3,y3}}
>
> and I want to produce the result (for fitting/plotting)
>
> data2 = {{f[x1],g[y1]},{f[x2],g[y2]},{f[x3],g[y3]}}
>
> I assume that if there was only one transform I wanted to apply, f[x],
> then I could say
> 	data2 = f[data]

No if you wanted

data2 = {{f[x1],f[y1]},{f[x2],f[y2]},{f[x3],f[y3]}}

you could do

Map[f, data, {Depth[data] - 1}]

there are other options.  f[data] is

f[{{x1,y1},{x2,y2},{x3,y3}}]

> but how about this more complicated transform with functions f and g?
>

It's not really more complicated, multiplication is a function too and 
your last request was to map multiplication across a list.  In general 
in Mathematica if you wish to perform an operation on a list you should 
first write the operation on each element, then use Map, Apply et. al. 
to operate on the list.  So the general operation on an element can be 
expressed as

h[{x_,y_}]:={f[x],g[y]}

Then we use Map

h/@data

Regards,

Ssezi



  • Prev by Date: Re: a little more complex list operation
  • Next by Date: Re: Mathematica newbie question : NDSolve
  • Previous by thread: Re: a little more complex list operation
  • Next by thread: Re: a little more complex list operation