This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Lexical Variables”.
1. Which makes it possible to define sophisticated generator procedures that produce new values?
a) List
b) Variables
c) Encapsulation
d) None of the mentioned
View Answer
Explanation: Encapsulation makes it possible to define sophisticated generator procedures that produce new values each time they are called.
2. Which primitive enables you to define one procedure inside another?
a) Do
b) List
c) Primitive
d) Labels
View Answer
Explanation: The labels primitive enables you to define one procedure inside another.
3. Which helps to produce nested fences?
a) Lets
b) List
c) Label
d) None of the mentioned
View Answer
Explanation: Lets helps to produce nested fences.
4. Which do not produce nested fences?
a) Variables
b) Procedure calls
c) Fences
d) All of the mentioned
View Answer
Explanation: Procedure calls do not produce nested fences.
5. Which makes nameless procedures into lexical closures?
a) $
b) #
c) #’
d) *
View Answer
Explanation: #’ makes it possible to produce nameless procedures into lexical closures.
6. What is the output of the given statement?
span class="sy0"> * (defun first-of-first-with-labels (l) (labels ((aux (m) (first m))) (first (aux 1)))) * (first-of-first-with-labels '((a b) (c d)))
a) A
b) B
c) C
d) D
View Answer
Explanation: This statement will produce the result as first given variable.
Output:
A
7. What is the output of the given statement?
span class="sy0"> * (defun power-of-two () (setf previous-power-of-two (* previous-power-of-two 2))) * (power-of-two) * (power-of-two)
a) 1
b) 2
c) 4
d) None of the mentioned
View Answer
Explanation: This statement will compute the power of two by executing certain number of times.
Output:
4
8. What is the output of the given statement?
span class="sy0"> * (defun square (list-of-numbers) (mapcar #'(lambda (n) (*n n)) list-of-numbers)) * (square '(1 2 3))
a) 9
b) 1
c) 3
d) 1 4 9
View Answer
Explanation: This statement will compute the square of all given numbers.
Output:
(1 4 9)
9. What is the output of the given statement?
span class="sy0"> * (setf square-procedures #'(lambda (n) (* n n))) * (funcall square-procedure 2)
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: This statement will compute the procedure of square using the given statement.
Output:
4
10. What is the output of the given statement?
span class="sy0"> * (setf g1 (let ((previous-power-of-two 1)) #'(lambda () (setf previous-power-of-two (*previous-power-of-two 2))))) * (g1)
a) G1
b) 0
c) Let
d) Error
View Answer
Explanation: This statement will create an error because of lag in number of arguments.
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
- Apply for Computer Science Internship
- Practice Computer Science MCQs