MTS 8: LISP and SLIP in MTS
June 1976
Functions That Create New LISP Structures
This section includes functions that create new LISP structures as
well as returning a value. Frequently, the value returned from a
function in this section is precisely the new LISP structure which
was created. Examples of these functions follow each description.
(CONS S1 S2) Returns the dotted pair of S1 and S2.
(CONS ’A ’B) = (A . B)
(CONS ’(A B C) ’(D E F)) = ((A B C)
.(D E F)) = ((A B C) D E F)
(CONS ’A ’(B C (D E))) = (A B C (D E))
(LIST S1...SN) Returns the list of S1 through SN.
(LIST ’A ’B) = (A B)
(LIST ’(A B C) ’(D E F)) = ((A B C) (D E F))
(LIST ’A ’(B C D)) = (A (B C D))
(EVLIS L) Evaluates each element of L and returns a list
of the values.
(EVLIS ’((ADD 3 1) (ADD 5 6))) = (4 11)
(CONC L1...LN) Returns a concatenated list of copies of lists
L1 through LN.
(CONC ’(A B C) ’(D E F)) = (A B C D E F)
(CONC ’(A B C) NIL ’(D E F)) = (A B C D E F)
(APPEND L S1...SN) Returns a copy of the list L, with S1 through
SN appended as elements to the end.
(APPEND ’(A B C) ’D ’E ’F) = (A B C D E F)
(APPEND ’(A B C) ’(D E) ’F) = (A B C (D E) F)
(APPEND NIL ’C ’D ’E) = (C D E)
(REVERSE L) Returns a list of the (top-level) elements of
L, in reverse order.
(REVERSE ’(A (B (C D)) E)) = (E (B (C D)) A)
(COPY S1 S2 S3) Returns a copy of structure S1. If arguments
S2 and S3 are given, each substructure of the
original structure (S1) which is EQUAL to S2
will be replaced by S3 in the copy. S2 need
not be a top-level element, but may be an
element at any level. If S2 appears without
S3, then all occurrences of S2 in the original
structure (except as the CDR of a dotted pair)
will be deleted in the copy. If the first
argument to COPY is a literal atom other than
20 LISP

MTS 8: LISP and SLIP in MTS
June 1976 Page Revised February 1979
NIL, the value of COPY will be a new atom,
which is not found on the OBJECT LIST, with
the same PNAME as the original atom. The
value of (COPY NIL) is NIL.
(COPY ’(A B C)) = (A B C)
(EQUAL L (COPY L)) = T
(EQ L (COPY L)) = NIL
(COPY ’(A (B) C) ’B) = (A NIL C)
(COPY ’(A B C (D B) E) ’B) = (A C (D) E)
(COPY ’(A B C (D B) E) ’D ’(L K)) =
(A B C ((L K) B) E)
(COPY ’A) = A
(EQ (COPY ’A) ’A) = NIL
(UNION L1 L2) Returns a list of the elements of L1 and the
elements of L2. No duplicate elements will
appear in the list returned, i.e., no two
elements will be EQ. The order of the ele-
ments in the resulting list will be L1 fol-
lowed by elements of L2 not in L1. Note:
| (UNION L NIL) may be used to generate a
| top-level copy of the list L, but all dupli-
| cate EQ entries will be deleted.
(UNION ’(A B C) ’(A B C D)) = (A B C D)
(INTERSECT L1 L2) Returns a list of the elements of L1 which are
EQ to elements of L2. No duplicate elements
will appear in the list returned. The order
of the resulting list will be the same as that
of L2.
(INTERSECT ’(A B B A) ’(A C)) = (A)
(EXCLUDE L1 L2) Returns a list of the elements of L2 which are
not EQ to elements of L1. No duplicate
elements will appear in the list returned.
The order of the resulting list will be the
same as that of L2.
(EXCLUDE ’(A B B A) ’(A C)) = (C)
(GENSYM A) Returns a unique atom. If no argument is
given, GENSYM creates atoms G1, G2, ..., etc.
Each time GENSYM is called, the GENSYM counter
is incremented by one. If a literal atom or
an IOARG is given to GENSYM, the PNAME of that
atom or of the buffer associated with the
IOARG will be used. This will be followed by
the current GENSYM counter. If the buffer
portion of the IOARG is NIL, the current
system output buffer will be used.
LISP 21
Previous Page Next Page