LISP Questions & Answers – Conditional

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Conditional”.

1. In clause what the zero or more additional forms are called?
a) Conditional
b) Consequents
c) Clause
d) None of the mentioned
View Answer

Answer: b
Explanation: It is used to move through the clauses and evaluating only the test form.

2. What is the value of last consequent form in the triggered clause?
a) Value of the entire COND
b) Trigger
c) Consequent
d) All of the mentioned
View Answer

Answer: a
Explanation: The value of the entire COND form is the value of the last consequent form in the triggered clause.

3. What will happen if the value of all the test-forms are nil?
a) Nothing
b) COND form is nil
c) Both Nothing & COND form is nil
d) None of the mentioned
View Answer

Answer: b
Explanation: If all the test forms are NIL then conditional will also return NIL.
advertisement
advertisement

4. Which has a template that calls for particularly peculiar argument evaluation?
a) COND
b) Consequent
c) Trigger
d) Sphere
View Answer

Answer: a
Explanation: COND is more versatile conditional and it has a template that calls for particularly peculiar argument evaluation.

5. Which checks the evaluated key form against the unevaluated keys using EQL?
a) COND
b) CASE
c) NIL
d) SETF
View Answer

Answer: b
Explanation: CASE checks the evaluated key form against the unevaluated keys using EQL and if the key is found, the corresponding clause is triggered.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What is the output of the given statement?

span class="sy0"> * (endp '(this is not empty))

a) T
b) NIL
c) Error
d) None of the mentioned
View Answer

Answer: b
Explanation: ENDP is recommended for empty lists, so it is printing NIL.
Output:
NIL
advertisement

7. What is the output of the given statement?

advertisement
span class="sy0"> * (evenp (* 10 8 6 4 2))

a) T
b) F
c) NIL
d) All of the mentioned
View Answer

Answer: a
Explanation: EVENP checks whether a given number is even or not.
Output:
T

8. What is the output of the given statement?

span class="sy0"> * (setf pets '(dog cat))
* (or (member 'dog pets) (member 'tiger pets))

a) Dog
b) Cat
c) Both Dog & Cat
d) None of the mentioned
View Answer

Answer: c
Explanation: OR will return nonNIL if any argument is nonNIL, So it is printing dog and cat.
Output:
(DOG CAT)

9. What is the output of the given statement?

span class="sy0"> * (setf day-or-date 'monday)
* (if (symbolp day-or-date) 'day 'date)

a) Monday
b) Day
c) Date
d) None of the mentioned
View Answer

Answer: b
Explanation: As a day is setted up by using setf, it is printing the value as day.
Output:
DAY

10. What is the output of the given statement?

span class="sy0"> * (setf high 98 temperature 102)
* (when (> temperature high) (setf high temperature) 'new-record)
* high

a) 98
b) 102
c) new
d) Error
View Answer

Answer: b
Explanation: This statement will compare the temperature, if higher is recorded, its value will be changed.
Output:
102

Sanfoundry Global Education & Learning Series – LISP Programming Language.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.