Page 1 of 1
Evalating Expressions
Posted: Tue Nov 18, 2014 4:31 am
by vignezds
Hello Everyone,
I am Very much new to LISP, I don't have basic knowledge in LISP but I supposed to do project in LISP. I need to evaluate given expression(Just addition, Subtraction, Multiplication, Division), kindly help me to do this. I am using LISPWORKS as tool.
Re: Evalating Expressions
Posted: Tue Nov 18, 2014 8:19 am
by Goheeca
You don't even specify the input!
However, I provide a generel answer.
If you have an arithmetic expression in s-expr form, you can easily evaluate it:
Code: Select all
(defvar arithmetic-expression '(+ 1 (* 5 6)))
(eval arithmetic-expression) ; = 31
For the standard infix notation of arithmetic expression, feel free to look at general description of
Shunting yard algorithm.
Re: Evalating Expressions
Posted: Tue Nov 18, 2014 8:25 am
by Goheeca
And on
Rosetta Code, you have
an implementation in CL of the arithmetic expression evaluation. Consider it as an inspiration only.
Re: Evalating Expressions
Posted: Thu Nov 20, 2014 11:15 am
by vignezds
Thank you so much, I got complete idea over it.
Goheeca wrote:And on
Rosetta Code, you have
an implementation in CL of the arithmetic expression evaluation. Consider it as an inspiration only.