Atoms are considered as S-expressions.
True
False
View Answer
Correct Answer: A — True
Explanation:
Atoms are also considered as S-expressions. Rather S-expressions are formed from atoms.
Browse topic-based LISP practice sets.
186 practice sets · Page 1 of 10
Atoms are considered as S-expressions.
True
False
Correct Answer: A — True
Explanation:
Atoms are also considered as S-expressions. Rather S-expressions are formed from atoms.
If X and Y are S-expression then (X.Y) is a/an ____
S-expression
Atom
List
Predicate
Correct Answer: A — S-expression
Explanation:
In LISP programming if X and Y are S-expressions then the dotted pair (X.Y) is also considered as S-expression.
What are the basic building blocks of S-expressions?
Atoms
Lists
Numbers
Predicates
Correct Answer: A — Atoms
Explanation:
Atoms are building blocks of S-expressions. Even atoms are considered as a fundamental unit of LISP.
All program statements and data in LISP are represented by S-expressions?
True
False
Correct Answer: A — True
Explanation:
Yes, all the program statements and data are represented by S-expressions in LISP. S-expressions or symbolic expressions are the syntactic elements of the LISP programming language.
What S-expression consists of?
Atoms and Lists
Numeric only
Literals only
Atoms only
Correct Answer: A — Atoms and Lists
Explanation:
S-expression consists of both Atoms and Lists. It also consists of numeric and literals.
Think of a way to write addition of four numbers using maximum possible braces?
(+ 1 2 3 4)
(+ (+ 1 2) (+ 3 4))
(+ 1 (+ 2 (+ 3 (4))))
(+ 1 2 (+ 3 4))
Correct Answer: B — (+ (+ 1 2) (+ 3 4))
Explanation:
In this 3 times braces () are used. Other possible way is (+ 1 (+ 2 (+ 3 4))) in which again 3 braces () are used.
Can LISP programs be nested?
Yes
No
Correct Answer: A — Yes
Explanation:
Yes, the LISP programs can be nested.
What is the basic syntax of LISP (Note: arg means argument here)
( ...)
( )
( )
( ... )
Correct Answer: A — ( ...)
Explanation:
Correct syntax of the LISP is ( ...).
How many arguments do a single LISP program has?
One
Two
Any number of arguments
Three
Correct Answer: C — Any number of arguments
Explanation:
Any number of arguments can come in LISP single program. As an example, the addition (+) primitive takes any number of arguments.
Arguments are ____ a part of LISP Syntax.
sometimes
always
vever
not considered as
Correct Answer: B — always
Explanation:
Argument is a part of basic syntax of LISP. Even if there is no argument given then NIL is considered to be one of the arguments.
Which of the following is part of basic syntax in LISP programming?
Primitive
NULL
#include
Correct Answer: A — Primitive
Explanation:
Primitives are part of basic syntax of LISP. + is not considered as a part of basic syntax of LISP. It is rather an example of the primitives.
Choose correct statement about arg1 of setq syntax.
It is a list
It is a symbol in which value is stored
It is an arithmetic operator
It is a primitive
Correct Answer: B — It is a symbol in which value is stored
Explanation:
In (setq arg1 arg2), the arg1 is like a variable in which value is stored. It can be a symbol. The value of arg2 got stored in it.
What can be used as an argument for a primitive?
Atoms and List
Another LISP programs
A user-defined function
Atoms, List, Another LISP program, Used-defined function
Correct Answer: D — Atoms, List, Another LISP program, Used-defined function
Explanation:
These all can be used as an argument for a primitive. Arguments depend on the type of primitive used. Example for arithmetic operators: numbers are used. For list functions: lists are used.
What is the notation used for writing LISP Syntax?
Prefix
Infix
Postfix
Different notations for different LISP Primitives
Correct Answer: A — Prefix
Explanation:
Prefix notation is always used in LISP Syntax. It doesn't change for different LISP Primitives. That is infix and postfix notations are not used.
In the syntax (setf arg1 arg2), what is arg2?
A variable
A value to be set on arg1
It is the definition of arg1
A formula
Correct Answer: B — A value to be set on arg1
Explanation:
In general, the arg2 or argument2 is the value that is to be set on arg1. It can be a number, a list, a symbol, a formula, etc.
In the syntax (setf arg1 arg2), what is arg1?
Value to be set
Variable on which value is set
Set of lists
Set of elements forming a list
Correct Answer: B — Variable on which value is set
Explanation:
The arg1 or argument 1 is like a variable in which value is stored. The arg1 can be anything like a symbol, a list or maybe the first element of a list, etc.
Does value of an actual parameter change in the procedure?
Yes
No
Sometimes
None of the mentioned
Correct Answer: C — Sometimes
Explanation:
The value of the actual parameter does not change only when the name of actual and formal parameters is same. In all other cases, the value of the actual parameter can change.
Can the actual parameters and formal parameters be of same name?
Yes
No
Correct Answer: A — Yes
Explanation:
Yes, the actual and formal parameters can be of same name. The scope of the formal parameter remains within the procedure in this case.
Can the parameters be passed to procedures in LISP?
No
Yes
Correct Answer: B — Yes
Explanation:
Yes, the parameters can be passed to procedures. Parameter passing is the most important part of the procedures. Actual parameters are passed to the procedures while function invoking.
Which primitive is used to define a procedure?
defun
defpro
defin
def
Correct Answer: A — defun
Explanation:
Defun is used for defining procedures. defun is the shorthand notation of deine function in LISP programming.