250+ TOP MCQs on LISP Primitives and Answers

LISP Questions and Answers for Aptitude test on “LISP Primitives”.

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

Answer: a
Clarification: 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

Answer: b
Clarification: 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

Answer: d
Clarification: 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

Answer: a
Clarification: 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

  250+ TOP MCQs on Macro and Answers

Answer: b
Clarification: 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

Answer: a
Clarification: Cons is used to merge two lists proved 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

Answer: b
Clarification: 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?

a) List
b) Arguments
c) It can be both List and argument
d) None of the mentioned

Answer: b
Clarification: 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

Answer: a
Clarification: Yes, the arithmetic operators are primitives in LISP programming language. For example: in (/ 3 3) / is a primitive.

  250+ TOP MCQs on Iteration and Answers

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

Answer: a
Clarification: 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

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top