| III. Function calls, parentheses, and blanks |
In LISP, a function call is written as a list. The CAR (first
element) of the list is the name of the function to be called, and CDR
(rest of the elements) is a list of S-expressions to be evaluated before being
passed to the function (except in a few special cases, such as QUOTE
and DEFUN).
For example, if A1 is the name of an atom and
L1 is the name of a list, then
(CONS A1 (CDR L1))
returns as value a new list which is like L1 except that
its first element has been replaced by A1.
You cannot use parentheses as freely in LISP as in other programming
languages; every parenthesis has a meaning. In particular, an atom
immediately following an open parenthesis is treated as the name of a
function. To test if two atoms are equal in value you may write
(EQ A1 A2), but if you accidentally write (EQ (A1
A2)), this says to call the function A1 with the
parameter A2 (a bad start), then use the result as the
single parameter to EQ (a bad ending).
Some LISP implementations are case-sensitive; they may require that
predefined names such as CONS be capitalized. Some implementations
may require that they be lowercase, e.g. cons. Some implementations
ignore case. Some implementations just treat everything as uppercase,
regardless of how you type it.
You may use whitespace (blanks, tabs, and newlines) to format LISP programs however you please.
|
|
|
![]() |