LISP Questions & Answers – Macro

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

1. Which uses their arguments to build intermediate forms and evaluating them to produce a value?
a) Backquote
b) Macros
c) List
d) Procedures
View Answer

Answer: b
Explanation: Macro use their arguments to build intermediate forms and it evaluate the intermediate form to produce a value.

2. Which keyword is used to define macro procedures?
a) Defun
b) Demacro
c) Defmacro
d) None of the mentioned
View Answer

Answer: c
Explanation: Defmacro can be used to define procedure called macro procedure.

3. Which do not evaluate their arguments?
a) List
b) Procedure
c) Setf
d) Macros
View Answer

Answer: d
Explanation: Macros do not evaluate their arguments.
advertisement
advertisement

4. What is the difference between the appearance of macro and ordinary definition?
a) Argument list
b) Reture value
c) Just the defining keyword
d) None of the mentioned
View Answer

Answer: c
Explanation: The only difference between the appearance of macro and ordinary definition is that one uses defmacro and other uses defun.

5. Which forms can be constructed with the same primitives that manipulate lisp expressions?
a) Lisp
b) Macro
c) Procedure
d) Defun
View Answer

Answer: a
Explanation: Lisp forms can be constructed with the same primitives that generally manipulate lisp expressions.

6. Which exploit the fact that lisp forms are just expressions meant to be evaluated?
a) List
b) Procedure
c) Macro
d) None of the mentioned
View Answer

Answer: c
Explanation: Macros exploit the fact that lisp forms are just expressions meant to be evaluated.

7. Pick out the correct statement about macro.
a) Macro is dependant
b) Macro is interoperable
c) Macro is complex
d) Macro deserve their own file
View Answer

Answer: d
Explanation: Macro deserve their own file for compiling them.
advertisement

8. What is the output of the given statement?

span class="sy0"> * (setf pressure -3)
* (when-plusp pressure (print 'alarm));

a) T
b) Nil
c) Alarm
d) None of the mentioned
View Answer

Answer: b
Explanation: This statement will print nil because of the negative number.
Output:
NIL
advertisement

9. What is the output of the given statement?

span class="sy0"> * (setf pressure 3)
* (when-plusp pressure (print 'alarm));

a) Alarm
b) Alarm
Alarm
c) 1
d) Nil
View Answer

Answer: b
Explanation: This statement will print alarm twice because of the positive number.
Output:
ALARM
ALARM

10. What is the output of the given statement?

span class="sy0"> * (defun when-plusp-with-bug (number result);
  (when (plusp number) result));
span class="sy0"> * (setf pressure -2)
* (when-plusp-with-bug pressure (print 'alarm))

a) Alarm
b) Nil
c) Both Alarm & Nil
d) None of the mentioned
View Answer

Answer: c
Explanation: This statement will print alarm and nil because of the definition.
Output:
ALARM
NIL

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.