Difficulty: Easy
Correct Answer: (setq y 'x')
Explanation:
Introduction / Context:
In Lisp, symbols can be manipulated as data. To store the literal symbol x
in a variable y
, you must prevent evaluation of x
. The quote operator (' or (quote …)) serves this purpose by yielding the symbol itself instead of its bound value.
Given Data / Assumptions:
setq
assigns to a variable without evaluating the variable name.
Concept / Approach:
Use (setq y 'x')
. Here, 'x evaluates to the symbol X. setq
stores that symbol in y
. Any forms that use ‘‘=’’ syntax are not Lisp and are therefore incorrect.
Step-by-Step Solution:
Verification / Alternative check:
In a REPL, after (setq y 'x'), (symbolp y) returns T and (eq y 'x') returns T.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting to quote the symbol or confusing set
and setq
semantics can result in unintended variable dereferencing.
Final Answer:
(setq y 'x')
Discussion & Comments