list应该是一个lambda表达式 [英] list should be a lambda expression

查看:111
本文介绍了list应该是一个lambda表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习LISP,我只是想了解它的逻辑,但是我遇到了一个错误,找不到解决方案..我敢肯定,这是因为我我在某处误用了括号,或者我在一般情况下误用了一个函数,但是我已经盯着它看了一个小时,而且没有取得任何进展!

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!

推荐答案

如果要编程,则需要学习编程语言的语法.

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

请咨询 Common Lisp Hyperspec 以了解Common Lisp语法. Common Lisp Hyperspec中用它的语法描述了Common Lisp的每个功能/宏/特殊运算符/....

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.

请参阅LET,IF的语法.

See the syntax for LET, IF.

LET需要绑定列表.

IFSETF是一种形式.需要用括号括起来.

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

NOT仅接受一个参数.

这篇关于list应该是一个lambda表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆