这样的表达式会导致错误
(= nil 3)
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
=(nil .......
那么有一种简单的方法(例如,另一个名为my-eq
的函数)使这个表达式返回nil
(意味着False),如下所示:
(my-eq nil 3)
=> nil
答案 0 :(得分:3)
那是eq
或equal
。
(eq 3 nil)
=>零
(eq OBJ1 OBJ2)
Return t if the two args are the same Lisp object.
(equal O1 O2)
Return t if two Lisp objects have similar structure and contents.
They must have the same data type.
Conses are compared by comparing the cars and the cdrs.
Vectors and strings are compared element by element.
Numbers are compared by value, but integers cannot equal floats.
(Use `=' if you want integers and floats to be able to be equal.)
Symbols must match exactly.