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
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
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
Explanation: Macros do not evaluate their arguments.
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
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
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
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
Explanation: Macro deserve their own file for compiling them.
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
Explanation: This statement will print nil because of the negative number.
Output:
NIL
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
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
Explanation: This statement will print alarm and nil because of the definition.
Output:
ALARM
NIL
Sanfoundry Global Education & Learning Series – LISP Programming Language.
To practice all areas of LISP, here is complete set of 250+ Multiple Choice Questions and Answers on LISP Programming Language.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check LISP Books
- Check Computer Science Books