我有两个项目。第一个 a-child
是一个列表,其中包含一个数组作为其第一个元素,然后是一些字符串作为其余元素。另一个 mapped
是一个包含多个数组的列表。通过检查,很容易看出 a-child
在 mapped
中,但我找不到可以为我找到它的函数。
对于下面糟糕的 lisp 风格,我深表歉意 - 我是几天前开始的,所以我还没有掌握所有约定。
(defparameter a-child (list (#2A((1 2 3) (7 4 5) (9 8 6))) "U" "R" "R"))
(defparameter mapped (list (#2A((1 2 3) (7 4 5) (9 8 6))) (#2A((1 2 3) (4 5 6) (7 8 9)))))
(find (car a-child) mapped) ;;returns NIL
(member (car a-child) mapped) ;;returns NIL
(position (car a-child) mapped) ;;returns NIL
(equalp (car a-child) (car mapped)) ;;returns T
我可以使用什么函数在数组列表中查找数组?谢谢。
最佳答案
答案
标记为“返回 NIL”的序列函数将返回 T
,如果您将 :test #'equalp
传递给它们。
原因
默认Two-Argument Test在 Common Lisp 中是 eql
.
它是 ANSI CL 标准提供的 4(!) 个通用比较函数之间最合理的选择:
另见 the difference between eq, eql, equal, and equalp in Common Lisp .
关于arrays - 测试数组是否在 lisp 中的列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19287777/