MathGroup Archive 2009

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

Search the Archive

Re: Modify variable names in a loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101790] Re: [mg101744] Modify variable names in a loop
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Fri, 17 Jul 2009 05:03:30 -0400 (EDT)
  • References: <200907161215.IAA02231@smc.vnet.net>

Hi,

it doesn't evaluate to what you want. You want to assign a Symbol but
you try to assigh a String.

For[kk = 1, kk <= 3, kk++, 
  Evaluate[Symbol["output" <> ToString[kk]]] = {kk, kk + 1, kk + 2};
];

should work.

Cheers
Patrick

On Thu, 2009-07-16 at 08:15 -0400, Parita wrote:
> Hi
> 
> I would like to modify the variable name in a loop and assign values
> to the variable.
> 
> For[kk = 1, kk <= 3, kk++,
>     "output" <> ToString[Evaluate[kk]] = {kk,kk+1,kk+2};
> ];
> 
> I would like the following output
> output1={1,2,3}
> output2={2,3,4}
> output3={3,4,5}
> 
> Although, "output" <> ToString[Evaluate[kk]] evaluates as expected, it
> does not let me assign values. Am I missing something here?
> 
> Thanks in advance for your help
> 



  • Prev by Date: Re: how to use vb.net/netlink to export a dxf file
  • Next by Date: Re: Modify variable names in a loop
  • Previous by thread: Re: Modify variable names in a loop
  • Next by thread: Re: Modify variable names in a loop