Difficulty: Easy
Correct Answer: cdr
Explanation:
Introduction / Context:
Lisp popularized symbolic AI with elegant list primitives. Two fundamental operations on lists are retrieving the first element and retrieving the remainder of the list after that first element is removed. Properly identifying these functions is essential in understanding recursive list algorithms, tree traversal, and pattern manipulation in AI code.
Given Data / Assumptions:
Concept / Approach:
car returns the first element of a list (the head). cdr returns the rest of the list (everything after the head). cons constructs a new list by adding a head element to an existing tail list. last returns the final cons cell or element depending on the dialect. Therefore, the function that returns the list after removing the first element is cdr.
Step-by-Step Solution:
1) Let L = (a b c d).2) car(L) = a; cdr(L) = (b c d).3) cons(x, L) = (x a b c d) for some x.4) last(L) = d (or (d) as a cell), depending on implementation.
Verification / Alternative check:
Run these primitives in any Lisp REPL. Applying cdr repeatedly walks down the list: cdr((a b c)) = (b c), then (c), then ().
Why Other Options Are Wrong:
Common Pitfalls:
Confusing car and cdr; forgetting that cdr returns a list (which may be empty) rather than a single element.
Final Answer:
cdr
Discussion & Comments