LISP Questions & Answers – Predicates – 1

This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “Predicates – 1”.

1. What is a procedure that returns a value that signals true or false?
a) List
b) Predicates
c) Data
d) None of the mentioned
View Answer

Answer: b
Explanation: A predicate is a procedure that returns a value that signals true or false.

2. Which primitive tests two arguments to see if their values are the same expression?
a) Equal
b) Eql
c) Eq
d) =
View Answer

Answer: a
Explanation: Equal primitive tests two arguments to see if their values are the same expression. It works on atoms and lists.

3. Which predicate tests to see if its first argument is an element of its second argument?
a) EQ
b) =
c) MEMBER
d) None of the mentioned
View Answer

Answer: c
Explanation: MEMBER will return what is left of the list when the matching symbol is encountered.
advertisement
advertisement

4. What is meant by keyword argument?
a) Arguments that follows a keyword
b) Lists
c) Data
d) Procedure
View Answer

Answer: a
Explanation: It is used to modify a procedure’s basic behaviour along the line.

5. Which is used to produce a procedure object from a procedure name?
a) EQ
b) #
c) EQUAL
d) None of the mentioned
View Answer

Answer: b
Explanation: From procedure name to produce procedure object # is used always.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. What is the output of the given statement?

span class="sy0"> * (equal (+ 2 2) 3)

a) T
b) NIL
c) F
d) Both NIL & F
View Answer

Answer: b
Explanation: As 4 is not equal 3, it is printing NIL.
Output:
NIL
advertisement

7. What is the output of the given statement?

advertisement
span class="sy0"> * (= '(this is a list) 1)

a) T
b) NIL
c) Error
d) None of the mentioned
View Answer

Answer: c
Explanation:= is used to test two numbers only.

8. What is the output of the given statement?

*(setf sentence '(a rough road leads to stars))
*(member 'stars sentence)

a) Stars
b) Road
c) Sentence
d) Leads
View Answer

Answer: a
Explanation: Member is used to see if its first argument is an element of its second argument.
Output:
(STARS)

9. What is the output of the given statement?

span class="sy0"> * (setf pairs '((maple shade) (apple fruit)))
* (member '(maple shade) pairs)

a) Shade
b) Maple
c) T
d) Nil
View Answer

Answer: d
Explanation: Any symbol beginning with a colon is said to be a keyword.
Output:
NIL

10. What is the output of the given statement?

span class="sy0"> * (setf predicate #'equal)
* (member '(maple shade) '((maple shade) (apple fruit)) :test predicate)

a) T
b) NIL
c) ((MAPLE SHADE) (APPLE FRUIT))
d) None of the mentioned
View Answer

Answer: c
Explanation: Procedure object is build from the procedure by using #, So it is printing ((MAPLE SHADE) (APPLE FRUIT)).
Output:
((MAPLE SHADE) (APPLE FRUIT))

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.