LISP Multiple Choice Questions on “LISP Primitives”.
1. Which is used to represent the prompt in lisp?
a) #
b) $
c) &
d) *
Answer: d
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: A procedures supplied by user in terms of lisp primitives is called user-defined procedure.
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
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: d
Clarification: This statement is used to add the two given values.
Output:
5.85
7. What is the output of the following statement?
span class="sy0"> * (first '( p h w))
a) P
b) H
c) W
d) phw
Answer: a
Clarification: 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
Answer: b
Clarification: 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))))))
Answer: d
Clarification: 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
Answer: c
Clarification: cdr function is used to form composite primitives.
Output:
(B C)