This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Evalating Expressions

4 posts · 4857 views

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

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:
(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.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Re: Evalating Expressions

And on Rosetta Code, you have an implementation in CL of the arithmetic expression evaluation. Consider it as an inspiration only.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Re: Evalating Expressions

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.