       Re: proper way to manipulate lists?

• To: mathgroup at smc.vnet.net
• Subject: [mg40196] Re: proper way to manipulate lists?
• From: bobhanlon at aol.com (Bob Hanlon)
• Date: Tue, 25 Mar 2003 14:49:00 -0500 (EST)
• References: <b5p158\$7sk\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```n=3;

data = Table[ToExpression[#<>ToString[k]& /@ {"x","y"}],{k,1,n}];

data2 = data /. {x_,y_}:>{a*x,b*y}

{{a x1,b y1},{a x2,b y2},{a x3,b y3}}

data3 = {a,b}*#& /@ data

{{a x1,b y1},{a x2,b y2},{a x3,b y3}}

Bob Hanlon

In article <b5p158\$7sk\$1 at smc.vnet.net>, Nathan Moore <nmoore at physics.umn.edu>
wrote:

<< Subject:	proper way to manipulate lists?
From:		Nathan Moore <nmoore at physics.umn.edu>
To: mathgroup at smc.vnet.net
Date:		Tue, 25 Mar 2003 07:40:24 +0000 (UTC)

I'm sure this is a one-liner, but it has stumped me for years.  Suppose
I'm working with a 2-d array of data,
data = {{x1,y1},{x2,y2}...{xN,yN}};
and I want to transform the data according to,
data2 = {{x1*a,y1*b},{x2*a,y2*b}...{xN*a,yN*b}};
The only way I know to do this is to move the data to excel,
performing the transform and then move the data back to Mathematica.  This
is crazy - there must be a better way - is there?  Please tell me there
is! >><BR><BR>

```

• Prev by Date: RE: proper way to manipulate lists?
• Next by Date: Re: proper way to manipulate lists?
• Previous by thread: RE: proper way to manipulate lists?
• Next by thread: Re: proper way to manipulate lists?