Re: Symbols, names, objects
- To: mathgroup at smc.vnet.net
- Subject: [mg6557] Re: [mg6515] Symbols, names, objects
- From: Richard Finley <trfin at fiona.umsmed.edu>
- Date: Tue, 1 Apr 1997 19:00:55 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
The problem, if I understand correctly what you are trying to do, is that you are not differentiating between the string "x" and a variable x. The string "x" is just that, a string, and cannot be assigned a value whereas the variable x, which superficially appears to be related to "x" and in fact looks the same in output form in Mma, are actually totally different animals. You therefore will have to define your operator in terms of true variables and not strings. At 02:43 AM 3/27/97 -0500, you wrote: >I need a function, let's call it Store, that takes two strings as >arguments -- the NAMES of two variables the second ov which variables >currently has some value -- and that causes the value in that variable >to be assigned to the symbol. (I don't care what the result returned >by the function is; Null will do just fine.) For example: > > temp = {1, 2, 3}; > Store["x", "temp"] > >After evaluating those expressions, the list {1,2,3} of numbers would >be assigned to the variable x. > >I tried the "obvious" thing: > > Store[newvar_String, datavar_String] := > (newvar<>"="<>datavar; Null) > >but that does not work. I've tried various alternatives, such as >inserting "Evaluate@"<> just before datavar in the above definition, >but that doesn't do it, either. > >More generally, I'd like Store to be able to accept as second argument >the string representation of any expression, where such expression, >when evaluated, give the value to be assigned to newvar. > >Evidently I'm having a lot of trouble juggling symbols, names of >symbols, values, etc., in Mathematica (3.0). > >Can you help me? > >-- > Murray Eisenberg Internet: murray at math.umass.edu > Mathematics & Statistics Dept. Voice: 413-545-2859 (W) > University of Massachusetts 413-549-1020 (H) > Amherst, MA 01003 Fax: 413-545-1801 > >