为什么成员函数返回nil

时间:2014-09-28 19:39:22

标签: lisp

我有一个清单:

*DSTATES* = ( ( list1 ) ( list2 ) ( list3 ) ... ( listn )  )

状态名称列表x = ( list )

*DSTATES*( (zero) (three two one) (two) (three zero) )

x有(two)

这是我的代码:

(map '() #'(lambda (x)
           (princ "Looking at transition ") (princ x)
           (princ #\newline)
           (if (and (eq '() (member x *DSTATES*)) (not (eq '() x)))
               (progn
                 (princ x) (princ " is not a member of *DSTATES*")
                 (princ #\newline)
                 (setq *DSTATES* (append *DSTATES* (list x)))))
           (princ "Intermediate *DSTATES* ") (princ *DSTATES*)
           (princ #\newline) (princ #\newline))
       trans)

当我做( eq '() ( member x *DSTATES* ) )它总是 - 据我所知 - 返回true。由于这个*DSTATES*变得越来越大,我的循环(*DSTATES*大小的停止条件永远不会终止。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

只需(member x *DSTATES* :test #'tree-equal)

这会使member检查会员资格。

希望有帮助的人

how to test whether one list is a member of another