LISP Questions and Answers for Freshers on “S-Expression”.
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
Answer: c
Clarification: 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.
2. What are examples of some of the atoms?
a) Numeric, Integer, Ratio
b) Numeric, Lists
c) Lists
d) Cons of two atoms
Answer: a
Clarification: 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 consered as List?
a) Number
b) T
c) NIL
d) Empty
Answer: d
Clarification: An empty thing is also consered 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
Answer: b
Clarification: 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?
a) ATOMS
b) error
c) A
d) Toms
Answer: a
Clarification: 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
Answer: c
Clarification: It works same as (write ‘argument) because LISP is case insensitive language.
7. What is the output of the following LISP statement?
a) A B C D
b) A
c) Error
d) B C D
Answer: a
Clarification: With use of write primitive, we can write space separated words with the use of braces.
Output: A B C D
8. What is the output of the following LISP statement?
a) 1
b) ‘ is not used so error occurs
c) Error
d) No output
Answer: a
Clarification: 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?
a) Ascii value of + dives by that of _
b) Error
c) +/_
d) + only
Answer: c
Clarification: 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?
a) Error
b) #
c) ASCII value of #
d) # will be printed without using ‘
Answer: a
Clarification: 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”.
