aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-05-26 20:36:22 +0000
committerRichard M. Stallman1998-05-26 20:36:22 +0000
commit74490e55dafccd6ebb1717c7144c5c36d6e0d838 (patch)
tree4f1a85d0c9b3c6c189f963f4da4762ef00bf5dc2
parent1911e6e52c846c4a5bf744d850ec7061ff90c412 (diff)
downloademacs-74490e55dafccd6ebb1717c7144c5c36d6e0d838.tar.gz
emacs-74490e55dafccd6ebb1717c7144c5c36d6e0d838.zip
*** empty log message ***
-rw-r--r--lispref/lists.texi32
1 files changed, 18 insertions, 14 deletions
diff --git a/lispref/lists.texi b/lispref/lists.texi
index bdc94dc015a..e20baaea5c2 100644
--- a/lispref/lists.texi
+++ b/lispref/lists.texi
@@ -32,9 +32,10 @@ the whole list.
32 32
33 Lists in Lisp are not a primitive data type; they are built up from 33 Lists in Lisp are not a primitive data type; they are built up from
34@dfn{cons cells}. A cons cell is a data object that represents an 34@dfn{cons cells}. A cons cell is a data object that represents an
35ordered pair. It records two Lisp objects, one labeled as the @sc{car}, 35ordered pair. It holds, or ``points to,'' two Lisp objects, one labeled
36and the other labeled as the @sc{cdr}. These names are traditional; see 36as the @sc{car}, and the other labeled as the @sc{cdr}. These names are
37@ref{Cons Cell Type}. @sc{cdr} is pronounced ``could-er.'' 37traditional; see @ref{Cons Cell Type}. @sc{cdr} is pronounced
38``could-er.''
38 39
39 A list is a series of cons cells chained together, one cons cell per 40 A list is a series of cons cells chained together, one cons cell per
40element of the list. By convention, the @sc{car}s of the cons cells are 41element of the list. By convention, the @sc{car}s of the cons cells are
@@ -82,10 +83,10 @@ made from two cons cells:
82 83
83 Each pair of boxes represents a cons cell. Each box ``refers to'', 84 Each pair of boxes represents a cons cell. Each box ``refers to'',
84``points to'' or ``contains'' a Lisp object. (These terms are 85``points to'' or ``contains'' a Lisp object. (These terms are
85synonymous.) The first box, which is the @sc{car} of the first cons 86synonymous.) The first box, which describes the @sc{car} of the first
86cell, contains the symbol @code{tulip}. The arrow from the @sc{cdr} of 87cons cell, contains the symbol @code{tulip}. The arrow from the
87the first cons cell to the second cons cell indicates that the @sc{cdr} 88@sc{cdr} box of the first cons cell to the second cons cell indicates
88of the first cons cell points to the second cons cell. 89that the @sc{cdr} of the first cons cell is the second cons cell.
89 90
90 The same list can be illustrated in a different sort of box notation 91 The same list can be illustrated in a different sort of box notation
91like this: 92like this:
@@ -668,8 +669,9 @@ different element.
668 669
669@defun setcar cons object 670@defun setcar cons object
670This function stores @var{object} as the new @sc{car} of @var{cons}, 671This function stores @var{object} as the new @sc{car} of @var{cons},
671replacing its previous @sc{car}. It returns the value @var{object}. 672replacing its previous @sc{car}. In other words, it changes the
672For example: 673@sc{car} slot of @var{cons} to point to @var{object}. It returns the
674value @var{object}. For example:
673 675
674@example 676@example
675@group 677@group
@@ -770,7 +772,9 @@ x2: |
770 772
771@defun setcdr cons object 773@defun setcdr cons object
772This function stores @var{object} as the new @sc{cdr} of @var{cons}, 774This function stores @var{object} as the new @sc{cdr} of @var{cons},
773replacing its previous @sc{cdr}. It returns the value @var{object}. 775replacing its previous @sc{cdr}. In other words, it changes the
776@sc{cdr} slot of @var{cons} to point to @var{object}. It returns the
777value @var{object}.
774@end defun 778@end defun
775 779
776 Here is an example of replacing the @sc{cdr} of a list with a 780 Here is an example of replacing the @sc{cdr} of a list with a
@@ -797,7 +801,7 @@ x
797 You can delete elements from the middle of a list by altering the 801 You can delete elements from the middle of a list by altering the
798@sc{cdr}s of the cons cells in the list. For example, here we delete 802@sc{cdr}s of the cons cells in the list. For example, here we delete
799the second element, @code{b}, from the list @code{(a b c)}, by changing 803the second element, @code{b}, from the list @code{(a b c)}, by changing
800the @sc{cdr} of the first cell: 804the @sc{cdr} of the first cons cell:
801 805
802@example 806@example
803@group 807@group
@@ -968,7 +972,7 @@ each time you run it! Here is what happens:
968 This function reverses the order of the elements of @var{list}. 972 This function reverses the order of the elements of @var{list}.
969Unlike @code{reverse}, @code{nreverse} alters its argument by reversing 973Unlike @code{reverse}, @code{nreverse} alters its argument by reversing
970the @sc{cdr}s in the cons cells forming the list. The cons cell that 974the @sc{cdr}s in the cons cells forming the list. The cons cell that
971used to be the last one in @var{list} becomes the first cell of the 975used to be the last one in @var{list} becomes the first cons cell of the
972value. 976value.
973 977
974 For example: 978 For example:
@@ -985,7 +989,7 @@ x
985 @result{} (4 3 2 1) 989 @result{} (4 3 2 1)
986@end group 990@end group
987@group 991@group
988;; @r{The cell that was first is now last.} 992;; @r{The cons cell that was first is now last.}
989x 993x
990 @result{} (1) 994 @result{} (1)
991@end group 995@end group
@@ -1249,7 +1253,7 @@ for another way to add an element to a list stored in a variable.
1249 1253
1250 An @dfn{association list}, or @dfn{alist} for short, records a mapping 1254 An @dfn{association list}, or @dfn{alist} for short, records a mapping
1251from keys to values. It is a list of cons cells called 1255from keys to values. It is a list of cons cells called
1252@dfn{associations}: the @sc{car} of each cell is the @dfn{key}, and the 1256@dfn{associations}: the @sc{car} of each cons cell is the @dfn{key}, and the
1253@sc{cdr} is the @dfn{associated value}.@footnote{This usage of ``key'' 1257@sc{cdr} is the @dfn{associated value}.@footnote{This usage of ``key''
1254is not related to the term ``key sequence''; it means a value used to 1258is not related to the term ``key sequence''; it means a value used to
1255look up an item in a table. In this case, the table is the alist, and 1259look up an item in a table. In this case, the table is the alist, and