list should be a lambda expression

↘锁芯ラ 提交于 2019-12-24 06:38:45

问题


I've just started learning LISP and I'm just getting my head around the logic for it, however I've run into an error I can't find the solution for..I'm sure it's because I've misused a parentheses somewhere or I've misused a function in general, but I've been staring at it for an hour now and haven't made any progress!

(defun not-touching (pos player move)
   (let (legal? t)
    if ((not (eq (member move '(0 1 2 3 4 7 8 11 12 13 14 15)) nil))
        (mapcar #'(lambda(x) (if (not (member move x) nil)
                                (cond ((and (eq (nth (- (position move x) 1) x) nil)
                                        (not (eq (nth (+ (position move x) 1) x) player))) t)   
                                    ((and (not (eq (nth (- (position move x) 1) x) player))
                                        (not (eq (nth (+ (position move x) 1) x) player))) t)
                                    ((and (not (eq (nth (- (position move x) 1) x) player))
                                        (eq (nth (+ (position move x) 1) x) nil)) t)
                                    (t setf legal? nil))
                                nil)) *outside-lines*))
    legal?))

and the error that I'm getting looks like this:

SYSTEM::%EXPAND-FORM: (NOT (EQ (MEMBER MOVE '(0 1 2 3 4 7 8 11 12 13 14 15)) NIL)) should be
  a lambda expression

Any help would be much appreciated!


回答1:


If you want to program, you need to learn the syntax of the programming language.

Consult the Common Lisp Hyperspec for Common Lisp syntax. Each function/macro/special operator/... of Common Lisp is described in the Common Lisp Hyperspec with its syntax.

See the syntax for LET, IF.

LET expects a list of bindings.

IF, SETF is a form. Needs parentheses around it.

NOT takes only one argument.



来源:https://stackoverflow.com/questions/12561779/list-should-be-a-lambda-expression

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!