How to get maxima variable value by its name string
Subject: How to get maxima variable value by its name string
From: Marco Verpelli
Date: Sat, 07 Dec 2013 20:31:15 +0100
In data 07 dicembre 2013 alle ore 18:15:56, - <mleoking at gmail.com> ha
scritto:
> Hi,
>
> Thanks the help from Jaime (Jaime Villate <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.
>
> If you know how to do this using maxima code, that would help as well.
>
> Thanks.
>
>> Leo
>
>
>
>
Have a look at sconcat.
var2:3+2$
<------- is a variable
var1:sconcat("3+2=",var2)$ <------- is a
string
str:sconcat("The value of var1 is: ",var1); <------- is also a string
produce:
The value of var1 is: 3+2=5
Regards
Marco Verpelli