MTS 8: LISP and SLIP in MTS
June 1976
(SETA ARR-ELT S) Sets the array element specified by ARR-ELT to
the value of S. ARR-ELT is an array element
specification of the same form used to get an
array element. SETA returns the value of S.
(SETA (B 3 4) ’(X Y) = (X Y), and the array
element (B 3 4) is set to (X Y).
(SETA (B (ADD 2 2) (SUB1 5)) (B (ADD 1 1) 3))
will return the value of (B 2 3), and the
array element (B 4 4) will be set to this
value.
(AND S1...SN) Evaluates the arguments S1 through SN in turn
until some Si has a value of NIL. AND then
stops evaluating and returns NIL. If no Si
has a value of NIL, AND returns the value of
SN.
(AND (CAR Z) (SETQ Z A) (SETQ X ’DONE)) has
the following effect: if (CAR Z) is NIL, AND
merely returns NIL; otherwise, Z is set to the
VALUE of A, and if the VALUE of A is NIL, then
AND returns NIL; otherwise, X is set to DONE,
and DONE is returned.
(OR S1...SN) Evaluates the arguments S1...SN until a value
which is not NIL is found. OR then returns
that value. If all of the arguments evaluate
to NIL, then OR returns NIL.
(OR (CAR Z) (SETQ Z A) (SETQ X ’DONE) (SETQ Y
NIL)) has the following effect: if ((CAR Z))
is non-NIL, returns CAR Z; otherwise, sets Z
to the VALUE of A. If the VALUE of A is
non-NIL, then returns that value. If the
VALUE of A is NIL, then sets X to DONE, and
returns DONE. Y will never be set to NIL.
(COND
(P1 S1...SN)
(P2 T1...TN)
.
.
(PN U1...UN)) This the basic conditional execution format
for LISP. The arguments to COND are one or
more COND-expressions of the form
(P S1...SN)
COND starts with the first COND-expression,
and evaluates P, which may be any LISP form.
If the value of P is non-NIL, COND will
30 LISP

MTS 8: LISP and SLIP in MTS
June 1976
evaluate S1...SN successively, and the value
returned from COND will be the value of SN.
If no Si is given, COND only returns the value
of P.
If the value of P IS NIL, then COND will go on
to the next COND-expression and repeat the
process. If the value of P for the last
COND-expression is NIL, then COND returns NIL.
It is seen that the functions AND and OR are
merely subcases of COND.
(AND S1...SN) = (COND
((NOT S1) NIL)
((NOT S2) NIL)
.
.
((NOT S(N-1)) NIL)
((SN)))
(AND S1...SN) = (COND
(S1 (COND
(S2 (COND...
.
.
(COND(S(N-1)SN))...)))))
(OR S1...SN) = (COND
(S1)
(S2)
.
.
(SN))
(SELECT EQUTHING
(E1 S1...SN)
(E2 T1...TN)
.
.
(EN U1...UN)
FAIL) This function is similar to COND, except the
values of E1...EN are tested to see if they
are EQUAL to the value of EQUTHING. If so,
then S1 through SN are evaluated, and the
value of SN is returned as the value of
SELECT.
If E1 does not match EQUTHING, then SELECT
goes on to (E2 T1...TN, etc. If E1 matches
EQUTHING, and no Si is given, then SELECT only
returns the value of E1.
LISP 31
Previous Page Next Page