LISP Questions & Answers – Procedure Definitions – 1

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

Answer: b
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

Answer: a
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

Answer: b
Explanation: A variable is a symbol thought of as a name for a place to store value.
advertisement
advertisement

4. How many types of variables are available in lisp?
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: b
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

Answer: c
Explanation: The parameter of a procedure are variables that are bound and have values assigned to them.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: d
Explanation: The statement will print the first and last value of the list because of the condition.
Output:
(BREAKFAST DINNER)
advertisement

7. What is the output of the following statement?

advertisement
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

Answer: b
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

Answer: d
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

Answer: a
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

Answer: c
Explanation: This statement is used to reverse the list.
Output:
(INSIDE OUTSIDE)

Sanfoundry Global Education & Learning Series – LISP Programming Language.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.