-1

我被一个家​​庭作业问题困住了。我正在尝试定义一个函数,该函数使用递归检查列表中是否存在元素。下面是我所拥有的。

(defun is-member2 (X S)
"Check if a X is a member of S"
(if  (and (atom X) (not (null S)) (lisp S) (> (length S) 0))

    ;X- is a value, not a set
    (if (equal X (car S))

        ;Located
        (equal 'a 'a)

        ;NotLocated
        (is-memeber2 X (cdr S))

    )

    ;No- X is not a value
    ()
);end if
)

但是,我不断得到它is-memeber2是未定义的。这让我相信要么X不再是有效元素,要么 ( cdr S) 正在发送nul,但我的 if 语句不应该抓住这个吗?

4

1 回答 1

3

is-member2不等于is-memeber2。检查你的拼写。

于 2012-09-26T14:54:40.503 回答