LISP Questions & Answers – String Manipulation – 2

This set of LISP Interview Questions and Answers for Experienced people focuses on “String Manipulation – 2”.

1. Symbol manipulation in LISP is called as _____
a) atoms
b) lists
c) list processing
d) none of the mentioned
View Answer

Answer: c
Explanation: Symbol manipulation in LISP is called as list processing. The full form of LISP is also List Processing.

2. Lists can be formed from ____
a) atoms
b) atoms and lists
c) lists
d) none of the mentioned
View Answer

Answer: b
Explanation: Both atoms and lists can be used to form lists. Lists can be made from atoms. But atoms cannot be made from lists because atoms are the fundamental unit of LISP.

3. Which of the following are general-purpose dialects of LISP?
a) Clojure
b) Common LISP
c) Common LISP and Scheme
d) Clojure, Command LISP and Scheme
View Answer

Answer: d
Explanation: The best-known general-purpose Lisp dialects are Clojure, Common Lisp, and Scheme.
advertisement
advertisement

4. What can be used to print “yes, no”?
a) (print “yes,no”)
b) (write “yes , no!”)
c) (print “yes,”)(print “,no”)
d) (print “yes”)(print “,”)(print “no”)
View Answer

Answer: a
Explanation: (print “yes,no”) will print yes,no. Write has exclamation mark (!) in its argument so not correct. Multiple prints used will print their arguments in new line. So, the two times and three times used print will not print “yes,no” continuously, hence these options are wrong.

5. Can write-line keyword be used for printing strings?
a) True
b) False
View Answer

Answer: a
Explanation: Write-line is also used to print the arguments. Other primitives used to print are print and write.

6. What will be the output of the following LISP statement?

(symbol-name 'ABC)

a) “ABC”
b) ABC
c) ‘ABC
d) None of the mentioned
View Answer

Answer: a
Explanation: “symbol-name” is used in symbol-manipulation. This primitive returns the argument provided to it in double quotes. So, here ABC was provided as argument and symbol-name return it as “ABC”.
Output: “ABC”
advertisement

7. What will be the output of the following LISP statement?

advertisement
(print '|ABC|)

a) |ABC|
b) ABC
c) “ABC”
d) None of the mentioned
View Answer

Answer: b
Explanation: In LISP programming the || are considered as escape characters. The use of these escape characters will print ABC on the output terminal. But these escape characters return string without showing || in output only when all the characters are capital letters.
Output: ABC

8. What will be the output of the following LISP statement?

(write (write "better"))

a) “better””better”
b) “better”
c) “better “better””
d) error will occur
View Answer

Answer: a
Explanation: In this statement the two write primitive are nested. The inner write will provide “better” as argument to outer write. Hence, both writes will print their arguments in output.
Output: “better””better”

9. What will be the output of the following LISP statement?

(write (print "better"))

a) “better””better”
b) “better”
c) error will occur
d) none of the mentioned
View Answer

Answer: a
Explanation: In this statement the print primitive is nested in write. The print primitive will provide “better” as argument to write and give output “better””better”.
Output: “better””better”

10. What will be the output of the following LISP statement?

(write ("welcome"))

a) welcome
b) “welcome”
c) no output due to error
d) both welcome and “welcome” are possible
View Answer

Answer: c
Explanation: The statement will show an error because “welcome” is kept in braces (). The use of braces will make the compiler to check if “welcome” is a symbol. But it is not a symbol so error will occur.

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.