我为什么会收到此错误:
值(2(2(2(2(2(2)2)2)2)2)2)不是类型数绑定SB-KERNEL :: X时[TYPE-ERROR类型的条件]
当使用以下测试功能调用subst-if
时:
(defun 2p (N) (= N 2))
(subst-if 3 #'2p '(2 (2 (2 (2 (2) 2) 2) 2) 2))
equal
函数中必须使用eql
或eql
(或任何可以比较任意值的函数,对于您的情况2p
更快),因为该函数必须能够接收任何值在您要传递的参数内(带有子列表的列表)。 =
功能用于数字。
(defun 2p (N) (eql N 2))
=
的定义:
* (describe #'=)
#<FUNCTION =>
[compiled function]
Lambda-list: (NUMBER &REST SB-KERNEL::MORE-NUMBERS)
Declared type: (FUNCTION (NUMBER &REST NUMBER)
(VALUES BOOLEAN &OPTIONAL))
Derived type: (FUNCTION (NUMBER &REST T) (VALUES BOOLEAN &OPTIONAL))
Documentation:
Return T if all of its arguments are numerically equal, NIL otherwise.
Known attributes: foldable, flushable, unsafely-flushable, movable, predicate, commutative
Source file: SYS:SRC;CODE;NUMBERS.LISP