You have to use equal
or eql
(or any function that can compare arbitrary values, for your case eql
being faster) in the 2p
function, as the function has to be able to receive any value inside the argument you're passing (the list with sublists). The =
function is meant for numbers.
(defun 2p (N) (eql N 2))
The definition for =
:
* (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