MathGroup Archive 2008

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

Search the Archive

Re: Local variable in ToExpression?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85548] Re: Local variable in ToExpression?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 13 Feb 2008 06:55:46 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <foudqm$ltq$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

test[] := Block[{result = 0}, ToExpression["result=1"]; result]

??

Regards
   Jens

karl.daggfeldt at gih.se wrote:
> Hi,
> How can I create a local variable from text in ToExpression?
> 
> test[] := Module[{result = 0}, 
> ToExpression["result=1"]; result]
> 
> test[] will return 0
> How can I make it return 1?
> (here ToExpression is creating a global variable; result=1, even though it is placed inside the Module)
> 
> Sincerely
> Karl Daggfeldt
> 


  • Prev by Date: Automatic Differentiation in Mathematica
  • Next by Date: Re: Troubles with HarmonicNumber, empty sums, and Zeta
  • Previous by thread: Local variable in ToExpression?
  • Next by thread: Re: Local variable in ToExpression?