Next: , Previous: , Up: Data   [Contents][Index]


16.4.3.2 Symbols—Lists

Two Lisp data types that we don’t commonly find in other languages are symbols and lists. Symbols are words. Ordinarily, they are converted to uppercase, regardless of how you type them:

> 'Artichoke
ARTICHOKE

Symbols do not (usually) evaluate to themselves, so if you want to refer to a symbol, you should quote it.

Lists are represeted as zero or more elements enclosed in parentheses. The elements can be of any type, including lists. You have to quote lists, or Lisp would take them for function calls:

> '(my 3 "Sons")
(MY 3 "Sons")
> '(the list (a b c) has 3 elements)
(THE LIST (A B C) HAS 3 ELEMENTS)

One quote protects a whole expression, including expressions within it.

You can build lists by calling list. Since list is a function, its arguments are evaluated. Here we call to ‘+’ with a call to list:

> (list 'my (+ 2 1) "Sons")
(MY 3 "Sons")