MTS 8: LISP and SLIP in MTS
Page Revised February 1979 June 1976
Arrays
LISP also supports arrays, where the value of an array element can
be any LISP structure. The subsection "Arrays" describes the
creation and use of arrays.
S-Expressions _____________
The basic LISP structure is a binary tree with atomic terminal nodes.
To represent these trees syntactically, symbolic expressions, called
S-expressions, are used. An S-expression consists of one of the
following:
(1) an atom,
(2) a dotted pair of S-expressions (S1 . S2), or
(3) a list of S-expressions (S1...SN)
Examples:
Syntax Tree Structure ______ ______________
(1) A .A
(2) (A . B) *
. .
A. .B
(3) ((A . B) . (C . (D . E))) *
. .
* *
. . . .
A. .B C. *
. .
D. .E
CAR and CDR
For any S-expression, the CAR is defined to be its entire lefthand
branch and its CDR to be its entire righthand branch. Thus the CAR
of ((A . B) . (C . (D . E))) is (A . B) and its CDR is (C . (D .
E)). Similarly, the CAR of (A . B) is A and its CDR is B. The
CAR of an atom is its VALUE, and the CDR of a literal atom is its
PLIST.
Lists
The list notation defined in LISP provides a convenient shorthand
which allows a subset of binary trees to be viewed as a list
structure. The prototype of a LISP list is the following
structure:
12 LISP