How to get maxima variable value by its name string



On 12/7/2013 9:15 AM, - wrote:
> Hi,
>
> Thanks the help from Jaime (Jaime Villate <villate at fe.up.pt 
> <mailto:villate at fe.up.pt>>), I was recently able to read and modify 
> some of the lisp source code of maxima.
>
> Now I want to write a lisp function that is able to replace variable 
> names in a string to their current values in maxima. For example:
>
> var2:3+2;
> var1:"3+2=$var2$";
> str: " The value of var1 is: $var1$";
> str2:name2value(str);
>
> I want str2 to be " The value of var1 is: 3+2=5" after running the 
> function name2value.
>
> I am struggling with how to get maxima variable value by its name 
> string (e.g. "var1") in lisp.
>
>
The maxima variable xyz  is associated with the lisp atom $XYZ.

(meval (intern (concatenate 'string "$"  "XYZ") :MAXIMA))

would do it.

oh, you may need (string-upcase "xyz")  which returns "XYZ")


and if you want to stick this back into a string,  read about (format 
nil " ..." ...)



RJF