MTS 8: LISP and SLIP in MTS
June 1976
(EQ ’A ’A) = T
(EQ ’(A B) ’(A B)) = NIL
(EQ 8 8) = NIL
(EQNAME A1 A2) Returns T if its arguments are literal atoms
or buffer atoms which have the same PNAME;
otherwise, returns NIL. EQNAME is equivalent
to EQ for normal atoms which are on the OBJECT
LIST. However, for buffer atoms and atoms
created by GENSYM, EQNAME provides a new and
useful function.
(EQNAME ’TEST ’TEST) = T
(EQNAME ’ANINPUTLINE IOARG) = T
if the buffer associated with IOARG has
as its contents "ANINPUTLINE".
(NUMBER A) Returns T if its argument is a numeric atom;
otherwise, returns NIL.
(NUMBER 3) = T
(SORT A1 A2) Returns T if the PNAME of its first argument
is less than or equal to its second argument
in standard EBCDIC collating sequence; other-
wise, returns NIL. A1 and A2 must be literal
atoms or IOARGs.
(SORT ’ABC ’ABB) = NIL
(SORT ’ABB ’ABB) = T
(SORT ’AB ’ABB) = T
(NULL S) NULL is equivalent to NOT.
List-Searching Operations
The functions in this section enable the user to break down LISP
structures into component structures in various ways. The result
will frequently depend on some particular substructure being found.
Examples of these functions follow each description.
(CAR L) Returns the CAR of any structure (i.e., the
first element of any list or the VALUE of an
atom).
(CAR ’((B C) D (E F))) = (B C)
(CDR L) Returns the CDR of any structure (i.e., the
list of remaining elements of any list or
PLIST of a literal atom). An attempt to take
the CDR of a numeric atom will generate a type
0 error.
18 LISP

MTS 8: LISP and SLIP in MTS
June 1976
(CDR ’((B C) D (E F))) = (D (E F))
(C...R L) These 28 functions perform all combinations of
up to four instances of CARs and CDRs.
(CAAR L) = (CAR (CAR L))
(CAAAAR L) = (CAR (CAR (CAR (CAR L))))
(CADADR L) = (CAR (CDR (CAR (CDR L))))
(CDDDR L) = (CDR (CDR (CDR L))))
(MEMBER S1 L) The list L is searched to see if S1 is EQUAL
to any element. If so, the sublist of L
starting with S1 is returned. If that element
is not EQUAL to any element of L, NIL is
returned.
(MEMBER ’A ’((A B) C (D E) G)) = NIL
(MEMBER ’(D E) ’((A B) C (D E) G)) = ((D E) G)
(ASSOC S1 L) The list L is searched to see if S1 is EQUAL
to the CAR of any element. If so, then that
element is returned. If S1 is not EQUAL to
the CAR of any element, NIL is returned.
(ASSOC ’A ’((A B) (C D) (E G))) = (A B)
(FIND S L N) The structure L is searched for any substruc-
ture (subtree) whose CAR is EQUAL to S. If N
is given, the Nth such substructure is return-
ed. If N is not given, the first such
substructure is returned. If N is zero or
negative, FIND will return the last such
substructure. If the substructure specified
is not found, FIND returns NIL.
(FIND ’B ’(A B C)) = (B C)
(FIND ’A ’(A (B (A C) D))) = (A (B (A C) D))
(FIND ’A ’(A (B (A C) D)) 2) = (A C)
(FIND ’(A C) ’(A (B (A C) D))) = ((A C) D)
(FIND ’(A C) ’(A (B (A C) D)) 2) = NIL
(NTH L N) Returns the sublist of L beginning with the
Nth element of L. If N is zero or negative,
NTH will return the last cell of L. If N is
greater than the number of elements of L, NTH
will return NIL.
(NTH ’(A B C) 1) = (A B C)
(NTH ’(A B C D) 3) = (C D)
(NTH ’(A B C D) 0) = (D)
(NTH ’(A B C D) 100) = NIL
LISP 19
Previous Page Next Page