Previous: , Up: Getting Started   [Index]


1.7 Summary

Types of LISP objects:

  1. s-expressions :: encompass everything we have seen, including both lists and atoms;
  2. lists :: sequences of s-expressions inside matching parentheses;
  3. atoms :: s-expressions the LISP treats as whole things. There are two kinds of attoms:
    • numbers
    • symbols (literal atoms); fill the roles of both variables and function names

We communicate with a LISP interpreter, which tries to evaluate each s-expression we type in. After evaluation, the intepreter prints the value if computed. This is called the top level of LISP.

Evaluation is done according to the following rules:

  1. Numbers evaluate to themselves;
  2. Symbols evaluate to the last value assigned to them;
  3. Lists are evaluated by interpreting the first element as a function name, and the rest of the list as arguments to that function. The arguments are (usually) evaluated, and the function applied to the resulting values. The value returned by the function is the value of the list.

We have seen the following functions:

  1. Arithmetic functions, like ‘+’, ‘1+’, and ‘*’. Some of these accept any number of arguments, and some, a fixed number. They all cause their arguments to be evaluated.
  2. The special function setq, which assigns its first argument, which should be a symbol, the value of its second argument.
  3. The system function exit. This is a function of no arguments that terminates the current LISP process.