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.
advertisement

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.

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.
advertisement

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.

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
advertisement

Sanfoundry Global Education & Learning Series – LISP Programming Language.

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn