This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Recursion”.
1. Which is bounded to a list of all unaccounted argument values?
a) REST
b) &REST
c) RAISE
d) &RAISE
View Answer
Explanation: A rest parameter will be marked by &REST and it is bounded to a list of all unaccounted argument values.
2. Which allow procedures to use themselves again?
a) Recursion
b) Reuse
c) Reintiate
d) None of the mentioned
View Answer
Explanation: Recursion allows procedures to use themselves again and again.
3. Which eliminate the need for many auxiliaries?
a) Parameters
b) Block parameters
c) Optional parameters
d) All of the mentioned
View Answer
Explanation: None.
4. Which can appear without an initial form?
a) Parameter
b) Block parameter
c) Optional parameter
d) Aux parameter
View Answer
Explanation: An aux parameter can appear without an initial form, in which case there are no surrounding parentheses.
5. What value will assigned, if there is no argument marked by a matching keyword?
a) T
b) NIL
c) False
d) Both NIL & False
View Answer
Explanation: If there is no argument marked by a matching keyword, the corresponding keyword parameter is bound to NIL.
6. What is the output of the following statement?
span class="sy0"> * (defun higher-level-expt (m n)(if (zerop n)1 (* m(lower-level-expt m (- n 1)))))
a) Higher
b) Higher-level-expt
c) Lower
d) Lower-level-expt
View Answer
Explanation: This statement will print higher-level-expt because it is defined atfirst.
Output:
HIGHER-LEVEL-EXPT
7. What is the output of the following statement?
span class="sy0"> * (defun root (x &optional n) (if n (expt x (/ 1 n))(sprt x))) * (root 27 3)
a) 3
b) 27
c) 3.0
d) None of the mentioned
View Answer
Explanation: This statement is used to find out the square root of the given value.
Output:
3.0
8. What is the output of the following statement?
span class="sy0"> * (defun punc (l) (append l '(period))) * (punc '(this))
a) This
b) Period
c) This period
d) All of the mentioned
View Answer
Explanation: This statement will append the period to the end of the given statement.
Output:
(THIS PERIOD)
9. What is the output of the following statement?
span class="sy0"> * (defun raise-aux (result number-list)(if (endp number-list) result (raise-aux (expt result (first number-list)) (rest number-list)))) * (defun raise (x &rest numbers) (raise-aux x numbers)) * (raise 5 3)
a) 5
b) 3
c) 125
d) 25
View Answer
Explanation: This statement will print first argument raised to power second argument.
Output:
125
10. What is the output of the following statement?
span class="sy0"> * (setf pairs '((maple shade) (apple fruit))) * (member '(maple shade) '((maple shade) (maple shade)) :test-not #'equal)
a) Maple
b) Shade
c) Nil
d) T
View Answer
Explanation: This statement is used to test the given statement for its equality.
Output:
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]
- Check Computer Science Books
- Check LISP Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship