MTS 8: LISP and SLIP in MTS
June 1976
Since EVAL calls itself in order to determine the values of the
argument-designators, the argument-designators do not have to be
atoms, but can be any LISP form which will evaluate to the desired
argument. For example, if the VALUE of X is 2 and the VALUE of Y
is 3, then EVALing the form
(ADD X (ADD Y 1))
causes the function ADD to be invoked twice--the first time with
arguments 3 and 1, and the final time with arguments 2 and 4.
Naturally, the VALUEs of X and Y are not altered by this operation.
There are a number of built-in LISP functions which are invoked by
a direct call as described above. In addition, the user can define
new functions by composing these built-in functions in various
ways, and then the user-defined functions can also be invoked by
name.
Output and Termination: (STOP) and (MTS)
Whenever a LISP form is EVALed, a resulting value is returned.
When the system reads and EVALs a form, it prints its (top-level)
value before reading the next form. When it is said that only the
top-level value is printed, this means that the evaluation of
arguments, which may involve intermediate function calls, does not
cause anything to be printed. For example, if a user enters the
form
(ADD X (ADD Y 1))
where the VALUE of X is 2 and the VALUE of Y is 3, the system EVALs
this entire expression and prints the resulting value of 6.
Evaluating the form (STOP) at any level terminates execution of
LISP. Evaluating the form (MTS) returns control to MTS command
mode from which the user may subsequently restart LISP via the
$RESTART command.
Basic LISP Functions ____________________
(QUOTE S) and ’S
It is important to remember that when a LISP form appears as an
argument-designator in a function call, this signifies that the
value of the form is to be the argument of the function. However,
many times LISP users wish to specify directly what an argument to
a function should be. In order to facilitate this process, the
function QUOTE is available. The value of (QUOTE A) is the atom A.
The value of (QUOTE (CAR (A B C))) is the list (CAR (A B C)).
16 LISP

MTS 8: LISP and SLIP in MTS
June 1976
If a user enters (CONS X Y) from the input stream, the system will
call the function CONS with the respective VALUEs of X and Y as
arguments. If the user enters (QUOTE (CONS X Y)), the system will
echo (CONS X Y), since that structure is the value of the input
form. If the user enters (CONS (QUOTE X) (QUOTE Y)), the system
will execute CONS, but its arguments will be the atoms X and Y
rather than their respective VALUEs. To make QUOTEing more
convenient, a shorter notation for QUOTE is defined in the system.
This is the character.
Examples:
’A is equivalent to (QUOTE A).
’(A (B C) D) is equivalent to (QUOTE (A (B C) D)).
Basic LISP Predicates
In general, a LISP predicate will return either the atom T,
indicating that it is true, or NIL, indicating that it is false.
Examples of these predicates follow each description.
(ATOM S) Returns T if its argument is an atom; other-
wise, returns NIL.
(ATOM ’A)=T
(ATOM ’(A B C )) = NIL
(NOT S) Returns T if its argument is NIL; otherwise,
returns NIL.
(NOT (CAR ’(A NIL B))) = NIL
(NOT (CAR (CDR ’(A NIL B)))) = T
(EQUAL S1 S2) Returns T if its arguments have the same LISP
structure or represent the same number; other-
wise, returns NIL.
(EQUAL ’(A B C) ’(A A B C)) = NIL
(EQUAL ’(A B C) (CDR ’(A A B C))) = T
(EQUAL 8 (TIMES 2 4)) = T
(EQ S1 S2) Returns T if its arguments are the same LISP
structure; otherwise, returns NIL. Since
there are frequently multiple structures which
represent the same S-expression, not every
pair of elements which are EQUAL are EQ; in
particular, numeric atoms which represent the
same number are not generally EQ. EQ is
almost always used with literal atomic argu-
ments, since there is only one copy of each
atomic name on the OBJECT LIST.
LISP 17
Previous Page Next Page