(defun calculate (exp)
(let ((stack '()))
(while (consp exp)
(if (memq (car exp) '(* /)) (setq stack (cons (funcall (car exp) (calc (car stack)) (calc (cadr exp))) (cdr stack))
exp (cddr exp))
(setq stack (cons (car exp) stack)
exp (cdr exp))))
(while (consp stack)
(if (memq (car stack) '(+ -)) (setq exp (funcall (car stack) (cadr stack) exp)
stack (cddr stack))
(setq exp (car stack)
stack (cdr stack))))
exp))