LISP Questions & Answers – S-Expression – 2

«
»

This set of LISP Questions and Answers for Freshers focuses on “S-Expression – 2”.

1. If S1, S2, S3… are S-expressions then list: (S1 S2 S3 ….) is a/an ____
a) Atom
b) Error will occur
c) S-expression
d) Primitive
View Answer

Answer: c
Explanation: According to recursive definition of S-expression if S1, S2, S3… are S-expressions then list: (S1 S2 S3 ….) is also an S-expression. S-expression is short form of symbolic expressions.
advertisement

2. What are examples of some of the atoms?
a) Numeric, Integer, Ratio
b) Numeric, Lists
c) Lists
d) Cons of two atoms
View Answer

Answer: a
Explanation: Atoms consist of Literals, Numbers, Integers, Ratios, Flonum. Lists are formed from atoms. Cons of two atoms is referred to as List.

3. Which of the following can be considered as List?
a) Number
b) T
c) NIL
d) Empty
View Answer

Answer: d
Explanation: An empty thing is also considered as List. Empty thing means the braces () with no arguments. Numbers are not counted in Lists.

4. Is LISP a case sensitive language.
a) Yes
b) No
View Answer

Answer: b
Explanation: LISP is not a case sensitive language. Example: (print ‘a) will behave same as (PRINT ‘A).

5. What is the output of the following LISP statement?

advertisement
(write 'ATOMS)

a) ATOMS
b) error
c) A
d) Toms
View Answer

Answer: a
Explanation: In LISP primitive programming language, write is a keyword that is used to print things on the output terminal of the compiler.
Output: ATOMS

6. What is the use of (WRITE ‘Argument)?
a) It converts argument in small letters to capital letters
b) It returns capital letters from the string
c) Same as (write ‘argument)
d) It converts the string into alphabetical order/sequence
View Answer

Answer: c
Explanation: It works same as (write ‘argument) because LISP is case insensitive language.

7. What is the output of the following LISP statement?

(write '(a b c d))

a) A B C D
b) A
c) Error
d) B C D
View Answer

Answer: a
Explanation: With use of write primitive, we can write space separated words with the use of braces.
Output: A B C D
advertisement

8. What is the output of the following LISP statement?

(write 1)

a) 1
b) ‘ is not used so error occurs
c) Error
d) No output
View Answer

Answer: a
Explanation: It will print number 1. If we use ‘1 then that will not be a number. ‘1 will convert number 1 to a list and it will have properties of list and not numbers.
Output: 1

9. What is the output of the following LISP statement?

advertisement
(write '+/_)

a) Ascii value of + divides by that of _
b) Error
c) +/_
d) + only
View Answer

Answer: c
Explanation: It will not print division of ASCII values of + and _. Write will print arguments as it is in the output.
Output: +/_

10. What is the output of the following LISP statement?

(write '#)

a) Error
b) #
c) ASCII value of #
d) # will be printed without using ‘
View Answer

Answer: a
Explanation: Compiler error will occur after the execution of this statement.
Output: Compiler error: “objects printed as # in view of *PRINT-LEVEL* cannot be read back in”.

Sanfoundry Global Education & Learning Series – LISP Programming Language.

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn