LISP Questions & Answers – Binding

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Binding”.

1. Which arranges for parameters to be bound on entering a procedure?
a) Form
b) Let
c) Initial
d) Parameter
View Answer

Answer: b
Explanation: LET arranges for parameters to be bound, just as parameter are bound on entering a procedure.

2. How does LET generally begins with?
a) Parameter list
b) Data
c) Fence
d) None of the mentioned
View Answer

Answer: a
Explanation: Parameter list consists of two-elements lists, each of which has a parameter variable and an intial value form.

3. What will happen if a variable had not assigned a value by SETF form?
a) Warning
b) Nothing will happen
c) Error message
d) Crash
View Answer

Answer: c
Explanation: Because of this condition, it will report an unbound variable error.
advertisement
advertisement

4. What is the alternative of LET for parameter binding?
a) Let
b) Let*
c) Let^
d) Let%
View Answer

Answer: b
Explanation: Let* is like shorthand notation for nested LETs.

5. Which helps you to write procedures on complicated things?
a) Development
b) Revoke
c) Progressive envelopment
d) All of the mentioned
View Answer

Answer: c
Explanation: Progressive envelopment helps you to write procedures on building complicated things incrementally.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. What is the output of the given statement?

span class="sy0"> * (setf x 'outside)
* (let* ((x 'inside) (y x))(list x y))

a) Inside Outside
b) Outside Inside
c) Outside Outside
d) Inside Inside
View Answer

Answer: d
Explanation: X’s and Y’s parameter are on inside only, So it is printing as Inside Inside.
Output:
(INSIDE INSIDE)
advertisement

7. What is the output of the given statement?

advertisement
span class="sy0"> * (defun both_ends (whole-list) 
  (let ((element (first whole-list)) (trailer (last whole-list))) 
  (cons element trailer)))

a) Both
b) Both_ends
c) Error
d) None of the mentioned
View Answer

Answer: b
Explanation: Atfirst element and trailer are assigned to initial value and then element and trailer are combined.
Output:
BOTH_ENDS

8. What is the output of the given statement?

span class="sy0"> * (defun both (l m) (cons (first l) (last m)))
* (both '(breakfast lunch) '(tea dinner))

a) Breakfast Lunch
b) Tea Dinner
c) Breakfast
d) Breakfast Dinner
View Answer

Answer: d
Explanation: The purpose of both is to combine the first element of one list with the last element of another.
Output:
(BREAKFAST DINNER)

9. What is the output of the given statement?

span class="sy0"> * (setf route '(boston cambridge lincoln concord))
* (cons (last route))

a) Boston
b) Cambridge
c) Lincoln
d) Concord
View Answer

Answer: d
Explanation: This statement will print last element of the list.
Output:
(CONCORD)

10. What is the output of the given statement?

span class="sy0"> * (setf abc-list '(a b c))
* (last abc-list)
* (first (last abc-list))

a) A
b) B
c) C
d) None of the mentioned
View Answer

Answer: c
Explanation: This statement will nest function of last with the first.
Output:
C

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.