micpro
Member level 2
I'm looking for a solution to evaluate mathematical arithmetic expressions in Skill.
Due to the mix of infix and postfix notations in Skill, evalstring doesn't always work. For example, "(3)*(4)" is a valid arithmetical expression, but evalstring can't evaluate it. Same for "2*(cos(17))".
Or consider these examples:
> evalstring("(4 +5)*3")
> 27
> evalstring("(4 -5)*3")
*Error* eval: not a function - 4
> evalstring("+4*3")
+4*3
^
SYNTAX ERROR found at line 1 column 2 of file *string*
*Error* lineread/read: syntax error encountered in input
> evalstring("4*(-5)")
-20
> evalstring("4*(+5)")
4*(+5)
^
SYNTAX ERROR found at line 1 column 5 of file *string*
*Error* lineread/read: syntax error encountered in input
and so on ...
Any ideas?
Due to the mix of infix and postfix notations in Skill, evalstring doesn't always work. For example, "(3)*(4)" is a valid arithmetical expression, but evalstring can't evaluate it. Same for "2*(cos(17))".
Or consider these examples:
> evalstring("(4 +5)*3")
> 27
> evalstring("(4 -5)*3")
*Error* eval: not a function - 4
> evalstring("+4*3")
+4*3
^
SYNTAX ERROR found at line 1 column 2 of file *string*
*Error* lineread/read: syntax error encountered in input
> evalstring("4*(-5)")
-20
> evalstring("4*(+5)")
4*(+5)
^
SYNTAX ERROR found at line 1 column 5 of file *string*
*Error* lineread/read: syntax error encountered in input
and so on ...
Any ideas?