Google News
logo
Lisp - Interview Questions
What about LISP - Data Types?
LISP data types can be categorized as.

Scalar types − for example, number types, characters, symbols etc.

Data structures − for example, lists, vectors, bit-vectors, and strings.

Any variable can take any LISP object as its value, unless you have declared it explicitly.

Although, it is not necessary to specify a data type for a LISP variable, however, it helps in certain loop expansions, in method declarations and some other situations that we will discuss in later chapters.

The data types are arranged into a hierarchy. A data type is a set of LISP objects and many objects may belong to one such set.
Example : Create new source code file named main.lisp and type the following code in it.
(setq x 10)
(setq y 34.567)
(setq ch nil)
(setq n 123.78)
(setq bg 11.0e+4)
(setq r 124/2)

(print x)
(print y)
(print n)
(print ch)
(print bg)
(print r)​

When you click the Execute button, or type Ctrl+E, LISP executes it immediately and the result returned is :
10
34.567
123.78
NIL
110000.0
62​
Advertisement