MathGroup Archive 2001

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

Search the Archive

Re: Programming Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30114] Re: [mg30109] Programming Problem
  • From: BobHanlon at aol.com
  • Date: Sat, 28 Jul 2001 22:08:51 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 2001/7/28 1:56:05 AM, schmitther at netcologne.de writes:

>I invoke a function in the form new["xyz"].
>In this function I want to assign something to a variable with the name
>xyz.
>Is this possible and if it is possible, how can it be done?
>

In[1]:=
new[x_String] := Module[{xvalue = ToExpression[x]}, 
      f = Sin[xvalue];
      ToExpression[x <> "=" <> ToString[f]]];

In[2]:=
xyz = 2;

In[3]:=
new["xyz"];

In[4]:=
xyz

Out[4]=
Sin[2]

In[5]:=
new["xyz"];

In[6]:=
xyz

Out[6]=
Sin[Sin[2]]


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Re: Pattern matching "on the fly"
  • Next by Date: Sum
  • Previous by thread: Programming Problem
  • Next by thread: Nested Trigonometry Functions