text2expr
-- convert a
character string to an expressiontext2expr
(text)
interprets the character
string text
as MuPAD input and generates the
corresponding object.
text2expr(text)
text |
- | a character string |
a MuPAD object.
coerce
, expr2text
, input
, int2text
, tbl2text
, text2int
, text2list
, text2tbl
text2expr
produces an error. Typically,
strings created from MuPAD objects via expr2text
can be reconverted to
corresponding objects.eval
.text
does not need to be terminated with a
``;
'' or a ``:
'' character,
respectively.text2expr
is a function of the system kernel.A character string is converted to a simple expression. The newly created expression is not evaluated automatically:
>> text2expr("21 + 21")
21 + 21
It may be evaluated via eval
:
>> eval(%)
42
A character string is converted to a statement sequence:
>> text2expr("x:= 3; x + 2 + 1"); eval(%)
(x := 3; x + 2 + 1) 6
>> x
3
>> delete x:
A matrix is converted to a string:
>> matrix([[a11, a12], [a21, a22]])
+- -+ | a11, a12 | | | | a21, a22 | +- -+
>> expr2text(%)
"Dom::Matrix()(array(1..2, 1..2, (1,1) = a11, (1,2) = a12, (2,\ 1) = a21, (2,2) = a22))"
The string is reconverted to a matrix:
>> text2expr(%)
Dom::Matrix()(array(1..2, 1..2, (1, 1) = a11, (1, 2) = a12, (2, 1) = a21, (2, 2) = a22))
>> eval(%)
+- -+ | a11, a12 | | | | a21, a22 | +- -+