This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Procedure Definitions – 1”.
1. Which is used to build the lisp procedures?
a) Data
b) Primitives
c) Definition
d) None of the mentioned
View Answer
Explanation: Lisp procedures are formed by using lisp primitives and it is the primary purpose of procedure definition.
2. Which primitive removes all but the last element from the list?
a) Last
b) First
c) Remove
d) Revoke
View Answer
Explanation: “Last” is used whenever there is a requirement of only last element of list.
3. What is a symbol thought of as a name for a place to store value?
a) Data
b) Variable
c) Parameters
d) None of the mentioned
View Answer
Explanation: A variable is a symbol thought of as a name for a place to store value.
4. How many types of variables are available in lisp?
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: There are two kinds of variables available in lisp. They are lexical variable and special variable.
5. What are the variables that are bound and that have values assigned to them?
a) Data
b) Variable
c) Parameters
d) None of the mentioned
View Answer
Explanation: The parameter of a procedure are variables that are bound and have values assigned to them.
6. What is the output of the following statement?
span class="sy0"> * (setf meals '(breakfast lunch tea dinner)) * (cons (first meals) (last meals))
a) Breakfast
b) Lunch
c) Dinner
d) Both Breakfast & Dinner
View Answer
Explanation: The statement will print the first and last value of the list because of the condition.
Output:
(BREAKFAST DINNER)
7. What is the output of the following statement?
span class="sy0"> * (setf whole-list '(monday tuesday wednesday thursday friday)) * (defun both-ends ()(setf whole-list (cons (first whole-list) (last whole-list))))
a) Monday
b) BOTH-ENDS
c) Friday Monday
d) Monday Friday
View Answer
Explanation: The function defun is used to return the procedure name only.
Output:
BOTH-ENDS
8. What is the output of the following statement?
span class="sy0"> * (defun both-ends-with-special ()(setf whole-list (cons (first whole-list) (last whole-list)))) * (setf whole-list '(monday tuesday wednesday thursday friday)) * (both-ends-with-special)
a) Monday
b) Friday
c) Wednesday
d) Both Monday & Friday
View Answer
Explanation: The value of whole-list is erected when a form involving both-ends-with-special is evaluated.
Output:
(MONDAY FRIDAY)
9. What is the output of the following statement?
span class="sy0"> * (setf meals '(breakfast lunch tea dinner)) * (first meals)
a) Breakfast
b) Lunch
c) Tea
d) Dinner
View Answer
Explanation: The keyword first is used to print the first item of the list.
Output:
(BREAKFAST)
10. What is the output of the following statement?
span class="sy0"> * (setf x 'outside) * (let ((x 'inside) (y x)) (list x y))
a) Outside
b) Inside
c) Inside Outside
d) Outside Inside
View Answer
Explanation: This statement is used to reverse the list.
Output:
(INSIDE OUTSIDE)
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.
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Check Computer Science Books
- Check LISP Books