下面的代码不断抛出以下错误:
caught ERROR:
illegal function call
(LET ((SOLUTION 'NIL) (FIRST 0) (SECOND 0))
(DOLIST (EL LST)
(IF (NUMBERP EL)
(PUSH EL SOLUTION)
((SETF #) (SETF #) (PUSH # SOLUTION))))
(CAR SOLUTION))
谁能明白为什么?从语法上讲,我看不出它有什么问题。注意:我正在使用 sbcl。
我的代码:
(defun evalpostfix (lst)
(let ((solution '())
(first 0)
(second 0))
(dolist (el lst)
(if (numberp el) ;if
(push el solution) ;then
((setf second (pop solution)) ;else
(setf first (pop solution))
(push (funcall el first second) solution))))
(car solution)))