This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Pattern Matching”.
1. Which procedure is used as key element in a backward chaining algorithm?
a) Matching
b) Unification matching
c) Verification
d) None of the mentioned
View Answer
Explanation: The unification matching procedure is a key element in a backward chaining.
2. What is the way of expressing an ordinary expression in terms of bits?
a) Datum
b) Data
c) Manipulation
d) Verification
View Answer
Explanation: The process of expressing an ordinary expression in terms of bits is called datum.
3. What is the name of elements present in patterns?
a) Variables
b) Patterns
c) Pattern variables
d) Pattern elements
View Answer
Explanation: Patterns can contain elements called pattern variables.
4. Which keeps variable binding on an association list?
a) Match
b) Compare
c) Equal
d) None of the mentioned
View Answer
Explanation: Match keeps variable binding on an association list.
5. Which is used to compare patterns and datums element by element?
a) Procedure
b) Compare
c) Equal
d) Matching
View Answer
Explanation: To compare patterns and datums element by element matching is used.
6. What is the output of the given statement?
span class="sy0"> * (setf pattern-variable-expression '(? x)) * (setf datum 'apple) * (setf bindings '((y red))) * (second pattern-variable-expression)
a) X
b) Red
c) Apple
d) None of the mentioned
View Answer
Explanation: The result will be x because the second element is referred in pattern.
Output:
X
7. What is the output of the given statement?
span class="sy0"> * (setf pattern-variable-expression '(? x)) * (setf datum 'apple) * (setf bindings '((y red))) * (list (second pattern-variable-expression) datum)
a) x
b) Y
c) Apple
d) Both x & Apple
View Answer
Explanation: The elements from the given list is listed using the given statement.
Output:
(X APPLE)
8. What is the output of the given statement?
span class="sy0"> * (cons (list (second pattern-variable-expression) datum) bindings)
a) (X apple)
b) (Y orange)
c) (X apple) (Y orange)
d) None of the mentioned
View Answer
Explanation: This statement will list all the elements in datum and bindings.
Output:
((X APPLE) (Y RED))
9. What is the output of the given statement?
span class="sy0"> * (defun add-binding (pattern-variable-expression datum bindings) (if (eq '_ (extract-variable pattern-variable-expression)) bindings (cons (make-binding (extract-variable pattern-variable-expression) datum) bindings))) * (add-binding '(? _) 'apple '((y red)))
a) X
b) Y
c) (X apple)
d) (Y red)
View Answer
Explanation: This statement is used for adding a binding in the pattern.
Output:
((Y RED))
10. What is the output of the given statement?
span class="sy0"> * (defun find-binding (pattern-variable-expression binding) (unless (eq '_(extract-variable pattern-variable-expression)) (assoc (extract-variable pattern-variable-expression) binding))) * (find-binding '(? _) '((x apple) (y red)))
a) X
b) Apple
c) T
d) Nil
View Answer
Explanation: This statement is used to find a binding in the given pattern.
Output:
NIL
Sanfoundry Global Education & Learning Series – LISP Programming Language.
To practice all areas of LISP, here is complete set of 250+ Multiple Choice Questions and Answers on LISP Programming Language.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Computer Science Books
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Check LISP Books