MathGroup Archive 1997

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

Search the Archive

Symbols, names, objects

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: trouble integrating Bessel Functions
  • Next by Date: Symbols, names, objects: kludge
  • Previous by thread: solving simple ODE using NDSolve
  • Next by thread: Fwd: Symbols, names, objects