Difficulty: Easy
Correct Answer: T
Explanation:
Introduction / Context:
Common Lisp provides arithmetic operators and numeric predicates that return truth values. The function minusp tests whether a number is strictly less than zero. This question combines arithmetic evaluation with a predicate: you must first compute the numeric result of a subtraction expression and then apply minusp to that result.
Given Data / Assumptions:
(- 20 4 8 8 1)
.(minusp <number>)
, which returns T if <number> < 0, else NIL.
Concept / Approach:
Compute the inner arithmetic first, then use the predicate. Remember that T is Lisp’s canonical true value and NIL is false. Some Lisps also print NIL for false, not “F”. Therefore, the final answer must respect Lisp’s true/false conventions.
Step-by-Step Solution:
(- 20 4 8 8 1)
→ start with 20.20 - 4 = 16.16 - 8 = 8.8 - 8 = 0.0 - 1 = -1.Now evaluate (minusp -1)
→ is -1 < 0? Yes.Thus, (minusp (- 20 4 8 8 1))
returns T.
Verification / Alternative check:
You can verify in a REPL: evaluating the arithmetic yields -1, and (minusp -1)
returns T. Testing a non-negative like 0 would return NIL because 0 is not negative in Lisp’s numeric predicates.
Why Other Options Are Wrong:
Common Pitfalls:
Mis-evaluating multi-argument subtraction; assuming 0 is negative; confusing NIL with F; forgetting Lisp’s truth values and evaluation order (inner form first).
Final Answer:
T
Discussion & Comments