MTS 8: LISP and SLIP in MTS
June 1976
(APPLY1 FN S1...SN) Causes the function FN to be invoked, where
S1...SN are the arguments of FN. FN may be
any LISP function specification.
(APPLY1 ’CAR ’(A B C)) = A
(APPLY1 ’CONS ’X ’Y) = (X.Y)
(MAP FN L1...LN) Causes the function FN to be called, with
L1...LN as its arguments, and then again with
(CDR L1)...(CDR LN) as its arguments, and then
to be called again with (CDDR L1)...(CDDR LN)
as its arguments, etc., until the shortest
list is exhausted. Thus, when MAP is used,
the arguments of FN will always be lists,
never atoms.
MAP returns NIL.
(MAPC FN L1...LN) Works like MAP except the CAR of each succes-
sive list is used as the argument to FN.
Thus, MAPC calls FN with (CAR L1)...(CAR LN)
as its arguments, and then with (CADR L1)...
(CADR LN), etc.
MAPC returns NIL.
(MAPLIST FN L1...LN) Causes the function FN to be called with
L1...LN as its arguments, and then with (CDR
L1)...(CDR LN), etc., just as in MAP. How-
ever, the value returned from MAPLIST is the
list of all the successive values returned
from FN.
(MAPCAR FN L1...LN) Works like MAPLIST except the CAR of each
successive list is used as the argument to FN.
MAPCAR returns a list of all the successive
values returned from FN.
(MAPCON FN L1...LN) Causes the function FN to be called with
L1...LN as its arguments, and then with (CDR
L1)...(CDR LN), just as in MAP. However, the
value returned from MAPCON is a concatenated
list of all the values returned from FN.
(MAPCAN FN L1...LN) Works like MAPCON except the CAR of each
successive list is used as the argument to FN.
MAPCAN returns a concatenated list of all the
values returned from FN.
Note: The user should be aware that the
values returned from FN, when called via
MAPCON or MAPCAN, must be lists, or an error
will result.
28 LISP

MTS 8: LISP and SLIP in MTS
June 1976
Warning: The user should be aware that MAPCON
and MAPCAN call GRAFT to create the concate-
nated list of values returned from FN. Thus,
the actual structures returned from FN will be
modified by MAPCON and MAPCAN. The possibili-
ties for creating circular lists are the same
as for GRAFT, RPLACA, etc.
Let the VALUE of X be ((D 7) (A 6) (N 5)),
then
(MAPLIST ’REVERSE X) = (((N 5)
(A 6) (D 7)) ((N 5) (A 6)) ((N 5))
(MAPCAR ’REVERSE X) = ((7 D) (6 A) (5 N))
(MAPCON ’REVERSE X) = ((N 5) (A 6)
(D 7) (N 5) (A 6) (N 5))
(MAPCAN ’REVERSE X) = (7 D 6 A 5 N)
N-Type Functions in LISP ________________________
There are a number of LISP functions which have the effect of
automatically QUOTEing their argument-designators. That is, the argu-
ments which are passed to the function by the LISP system are the
argument-designators themselves, rather than their values. The function
called can then evaluate the arguments selectively by calling EVAL.
This is the mechanism used by LISP to implement conditional execution,
or conditional evaluation.
(SETQ A1 S1...AN SN) Sets arguments A1...AN to the values of argu-
ments S1...SN, respectively.
(SETQ X (CAR ’(B C)) Y ’A) = A, and the VALUE
of X becomes B, and the VALUE of Y becomes A.
Note: If the VALUE of X is VALX, then (SET ’X
’(B C) ’Y X) = VALX, and X is set to (BC), and
Y is set to VALX, since the arguments to SET
are EVALed before SET is called. However,
(SETQ X ’(B C) Y X) = (B C), and X is set to
(BC), and Y is set to (B C), since the SETQ
performs an EVAL-SET-EVAL-SET... loop.
(UNCONS L A) Returns the CAR of the VALUE of L, and also
sets A to the CDR of L.
(UNCONS ’(A B C) X) = A, and the VALUE of X
becomes (B C).
If the VALUE of L is (A B C), then (SETQ M
(UNCONS L L)) = A, and the VALUE of L becomes
(B C), and the VALUE of M becomes A.
LISP 29
Previous Page Next Page