Lisp非法函数调用,

1 lisp compiler-errors common-lisp

下面的代码不断抛出以下错误:

 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))
Run Code Online (Sandbox Code Playgroud)

谁能明白为什么?从语法上来说,我看不出它有什么问题.注意:我正在使用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)))
Run Code Online (Sandbox Code Playgroud)

Rai*_*wig 5

((setf second (pop solution)) - 两个开括号?为什么?IF使用else表单的语法是:

(if test-form then-form else-form)
Run Code Online (Sandbox Code Playgroud)

表单不能以两个括号开头 - 只有一个例外:((lambda (x) (+ x 1)) 2).

如果要对多个表达式进行分组,请使用类似的内容(progn a b c ... z).