MTS 8: LISP and SLIP in MTS
Page Revised February 1979 June 1976
The GENSYM counter can be reset by using the
STATUS function.
Note: An atom created by GENSYM is not placed
in the system OBJECT LIST. Thus, if an atom
with the same PNAME is created during a READ,
it will not refer to the same atom which was
created by GENSYM. The user may remove any
atom from the OBJECT LIST by calling the
function REMOB.
(SET ’GENSET (GENSYM ’ATOM)) = ATOM1
(EQ GENSET ’ATOM1) = NIL
(EQNAME GENSET ’ATOM1) = T
(EXPLODE A) Returns a list of the single-character atoms
of the PNAME of A. A must be a literal atom,
or an IOARG, in which case the PNAME of its
associated buffer will be used. If the buffer
portion of an IOARG is NIL, the system output
buffer will be used.
(IMPLODE LA) Returns an atom whose PNAME is the concatena-
tion of the PNAMEs of the elements of LA. The
atom returned is not on the OBJECT LIST.
Functions That Modify Existing LISP Structures
(SET A1 S1...AN SN) The VALUE of Ai is set to Si for each "i", and
the value returned from SET is the last Si.
(SET ’X ’A ’Y ’(B C)) = (B C),
The VALUE of X is set to A, the VALUE of
Y to (B C).
(RPLACA S1 S2) Replaces the CAR of S1 with S2 and returns the
new structure.
(RPLACA ’(A B C) ’(E F)) = ((E F) B C)
(RPLACD S1 S2) Replaces the CDR of S1 with S2 and returns the
new structure.
(RPLACD ’(A B C) ’(D E)) = (A D E)
Note: RPLACA and RPLACD actually modify the
structures sent to them as arguments, unlike
functions such as CONC, APPEND, and COPY,
which create entirely new structures with the
desired properties. Because of this, RPLACA
and RPLACD should be used with great caution.
It is very easy to create circular LISP
22 LISP

MTS 8: LISP and SLIP in MTS
June 1976
structures using these functions, and attempts
to process such structures can cost a great
deal before the user discovers the program is
in an infinite loop. For example, if L =
(A B), then (RPLACA L L) creates the
structure:
...*
|.. .
*
B. .NIL
(DELETE S L N) Deletes up to N occurrences of expression S
from the list L. If no N is given, all
occurrences are deleted. S must occur as a
top-level element of the list L. DELETE
returns the new list L.
(DELETE ’C ’(A B C D C D C D) 2) =
(A B D D C D)
(DELETE ’C ’(A B C D (C D) C D)) =
(A B D (C D) D)
If the VALUE of L is (A B C), then (DELETE
’B L) = (A C), and the VALUE of L is (A C).
However, (DELETE ’A L) = (B C), but the VALUE
of L is still (A B C). Thus, DELETEing the
CAR of a list L is equivalent to taking the
CDR of L, but DELETEing any other element will
cause an actual change in the list structure.
If multiple occurrences of an element are
DELETEd from a list, it is as though multiple
DELETE operations had been performed, each one
on the result of the previous one. Thus, if
the VALUE of L is (A A A B), then (DELETE
’A L) = (B). Note that the VALUE of L remains
(A A A B), since nothing has occurred to alter
the list structure (A A A B).
(GRAFT L1...LN) Creates a concatenated list of L1 through LN
by actually modifying list Li so that it
becomes Li...LN. Thus, list LN is "grafted"
onto the end of list L(n-1), and then list
L(n-1) is grafted onto the end of list L(n-2),
etc. The value of GRAFT will be the (modi-
fied) list L1.
For example, if the VALUE of X is (A B), the
VALUE of Y is (C D), and the VALUE of Z is
(E F), then (GRAFT X Y Z) = (A B C D E F), and
the VALUE of Z is (E F), the VALUE of Y is
LISP 23
Previous Page Next Page