MathGroup Archive 1997

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

Search the Archive

Fwd: Symbols, names, objects

  • To: mathgroup at
  • Subject: [mg6541] Fwd: [mg6515] Symbols, names, objects
  • From: BobHanlon at
  • Date: Mon, 31 Mar 1997 23:01:40 -0500 (EST)
  • Sender: owner-wri-mathgroup at

Store[newvar_String, datavar_String] :=
       (ToExpression[newvar<>"="<>datavar]; Null)
temp = {1, 2, 3}; Store["x", "temp"]; x

Bob Hanlon
>Forwarded message:
>From:	murray at (Murray Eisenberg)
>To: mathgroup at

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
  Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
  University of Massachusetts                       413-549-1020 (H)
  Amherst, MA 01003                           Fax:  413-545-1801

  • Prev by Date: Re: Symbols, names, objects: kludge
  • Next by Date: Re: Bug: V.3 for PowerMac
  • Previous by thread: Re: Symbols, names, objects
  • Next by thread: Re: Symbols, names, objects