Difficulty: Easy
Correct Answer: (consp
Explanation:
Introduction / Context:
LISP lists are built from CONS cells—pairs consisting of a head (car) and a tail (cdr). Recognizing list structure at runtime is a common need in symbolic processing. LISP provides type predicates to test the nature of objects. This question asks for the predicate that checks whether an object is specifically a CONS cell.
Given Data / Assumptions:
Concept / Approach:
The predicate consp returns t when its argument is a CONS cell. By contrast, cons constructs a new CONS cell and is not a predicate, and eq tests identity between two objects, not type. The misspelled form ‘‘(cous =
Step-by-Step Solution:
Verification / Alternative check:
In a Common Lisp REPL: (consp '(a b)) → t; (consp 'a) → nil. This confirms the predicate's behavior.
Why Other Options Are Wrong:
(cons
(eq
(cous =
None: Incorrect because consp is the precise predicate.
Common Pitfalls:
Confusing constructors with predicates; overlooking arity requirements in predicate forms.
Final Answer:
(consp
Discussion & Comments