This set of LISP Multiple Choice Questions & Answers (MCQs) focuses on “LISP Primitives – 2”.
1. Choose the correct option for the output when lower or upper-case arguments are given in LISP.
a) Same output
b) Different output
c) LISP does not support lower case
d) LISP does not support upper case
View Answer
Explanation: LISP gives the same output for both the cases. In fact, LISP always gives output in upper case letters.
2. Which primitive can be used to create a list?
a) getf
b) setf
c) make
d) none of the mentioned
View Answer
Explanation: Setf is used to create the list. Getf is used to retrieve the data from list. Make is not a primitive in LISP.
3. What are the elements in list: tap in following LISP statement?
(setf tap '(water oil grease))
a) Water
b) Oil
c) Grease
d) Water oil grease
View Answer
Explanation: Setf is the primitive used to create a list. Tap will be initialised to water oil grease with the given statement.
Output: WATER OIL GREASE
4. Which primitive can be used to remove an element from List?
a) delete
b) cons
c) cdr
d) write
View Answer
Explanation: Delete is the primitive used to remove an element from list. The element to be removed is passed as an argument to delete primitive along with the list name from which element is to be deleted and delete will remove that element from list.
5. Which primitive can be used to add an element to List?
a) delete
b) cons
c) cdr
d) write
View Answer
Explanation: Cons is the primitive used to add an element to list. Cons take two lists as an argument and merge them to form a new list.
6. What is the output of the following LISP program?
(setf chess '(king queen)) (write (cons 'rook chess))
a) rook king queen
b) king queen rook
c) king queen
d) rook
View Answer
Explanation: Cons is used to merge two lists provided to it as an argument. Here one list is rook and other is chess. So, cons will merge rook with chess at form a new list: rook king queen.
Output: ROOK KING QUEEN
7. What is the output of the following LISP program?
(setf cricket '(bat ball racquet)) (write (delete 'racquet cricket))
a) bat ball racquet
b) bat ball
c) racquet bat ball
d) racquet
View Answer
Explanation: Delete is given racquet as an argument to delete it from list cricket. So, it will delete racquet from the list cricket to form a new list: bat ball.
Output: BAT BALL
8. What are 2 and 3 referred as in the following LISP statement?
(+ 2 3)
a) List
b) Arguments
c) It can be both List and argument
d) None of the mentioned
View Answer
Explanation: In LISP programming basic syntax, the first thing written is primitive and then arguments are written. So, in this way + is a primitive and 2,3 are arguments.
9. Are arithmetic operators primitives in LISP?
a) True
b) False
View Answer
Explanation: Yes, the arithmetic operators are primitives in LISP programming language. For example: in (/ 3 3) / is a primitive.
10. What is the output of (/ 6 3) and (- 6 4)?
a) 2 2
b) 1/2 2
c) 2 -2
d) 1/2 -2
View Answer
Explanation: Syntax of the LISP takes prefix expressions. So, 6/3=2 and 6-4=2 will be the outputs of the following statements.
Output: 2,2
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.
- Apply for Computer Science Internship
- Check Computer Science Books
- Check LISP Books
- Practice Computer Science MCQs