LISP Questions & Answers – LISP Primitives – 1

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

1. Which is used to represent the prompt in lisp?
a) #
b) $
c) &
d) *
View Answer

Answer: d
Explanation: Lisp displays a prompt to to tell that it waiting for something to enter.

2. Which notation facilitates uniformity in lisp?
a) Prefix
b) Postfix
c) Infix
d) None of the mentioned
View Answer

Answer: a
Explanation: Because the procedure name is always in the same place, no matter how many arguments are involved.

3. Which is a procedures supplied by user in terms of primitives?
a) Custom
b) User-defined
c) Definite
d) All of the mentioned
View Answer

Answer: b
Explanation: A procedures supplied by user in terms of lisp primitives is called user-defined procedure.
advertisement
advertisement

4. What is the process of reserving a place in computer memory to store a value for a symbol?
a) Storing
b) Ranging
c) Binding
d) None of the mentioned
View Answer

Answer: c
Explanation: Binding means that allotting a memory location to a variable and storing a value in it.

5. What is the general pattern that shows how the various parts of an expression fit together?
a) Template
b) Pattern
c) Match
d) Both Template & Pattern
View Answer

Answer: a
Explanation: Template describes what should appear in the position occupied.

6. What is the output of the following statement?

span class="sy0"> * (+ 3.14 2.71)

a) 3.14
b) 2.71
c) 5.84
d) 5.85
View Answer

Answer: d
Explanation: This statement is used to add the two given values.
Output:
5.85
advertisement

7. What is the output of the following statement?

advertisement
span class="sy0"> * (first '( p h w))

a) P
b) H
c) W
d) phw
View Answer

Answer: a
Explanation: This statement will print the first alphabet of the given value.
Output:
P

8. What is the output of the following statement?

span class="sy0"> * ( first (rest (first '((a b) (c d)))))

a) a
b) b
c) c
d) d
View Answer

Answer: b
Explanation: This statement is used to print b because of nesting.
Output:
b

9. What is the output of the following statement?

span class="sy0"> * '(first (first (rest (rest ((a b) (c d) (e f))))))

a) a
b) b
c) ab
d) (FIRST (FIRST (REST (REST ((A B) (C D) (E F))))))
View Answer

Answer: d
Explanation: Because ‘ character is recognized as a macro character, so it will convert ‘ into (quote ).
Output:
(FIRST (FIRST (REST (REST ((A B) (C D) (E F))))))

10. What is the output of the following statement?

span class="sy0"> * (cdr '(a b c))

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

Answer: c
Explanation: cdr function is used to form composite primitives.
Output:
(B C)

Sanfoundry Global Education & Learning Series – LISP Programming Language.

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.