(Fmessage): Check byte size (instead of char size) of
[bpt/emacs.git] / lispref / lists.texi
index 7f0fc81..da9d573 100644 (file)
@@ -211,7 +211,7 @@ considered a list and @code{not} when it is considered a truth value
 @end example
 @end defun
 
-@need 1000
+@need 2000
 
 @node List Elements
 @section Accessing Elements of Lists
@@ -543,9 +543,9 @@ Here are some examples where the final argument is not a list:
 
 @example
 (append '(x y) 'z)
-     @result{} (x y z)
+     @result{} (x y z)
 (append '(x y) [z])
-     @result{} (x y [z])
+     @result{} (x y [z])
 @end example
 
 @noindent
@@ -554,34 +554,14 @@ not a list, the sequence's elements do not become elements of the
 resulting list.  Instead, the sequence becomes the final @sc{cdr}, like
 any other non-list final argument.
 
-Integers are also allowed as arguments to @code{append}.  They are
-converted to strings of digits making up the decimal print
-representation of the integer, and these strings are then appended.
-Here's what happens:
-
-@example
-@group
-(setq trees '(pine oak))
-     @result{} (pine oak)
-@end group
-@group
-(char-to-string 54)
-     @result{} "6"
-@end group
-@group
-(setq longer-list (append trees 6 '(spruce)))
-     @result{} (pine oak 54 spruce)
-@end group
-@group
-(setq x-list (append trees 6 6))
-     @result{} (pine oak 54 . 6)
-@end group
-@end example
-
-This special case exists for compatibility with Mocklisp, and we don't
-recommend you take advantage of it.  If you want to convert an integer
-in this way, use @code{format} (@pxref{Formatting Strings}) or
-@code{number-to-string} (@pxref{String Conversion}).
+The @code{append} function also allows integers as arguments.  It
+converts them to strings of digits, making up the decimal print
+representation of the integer, and then uses the strings instead of the
+original integers.  @strong{Don't use this feature; we plan to eliminate
+it.  If you already use this feature, change your programs now!}  The
+proper way to convert an integer to a decimal number in this way is with
+@code{format} (@pxref{Formatting Strings}) or @code{number-to-string}
+(@pxref{String Conversion}).
 @end defun
 
 @defun reverse list
@@ -776,6 +756,7 @@ x1
 @end group
 @end example
 
+@need 4000
   Here is the result in box notation:
 
 @example
@@ -999,11 +980,6 @@ function would create new cons cells to store the elements in their
 sorted order.  If you wish to make a sorted copy without destroying the
 original, copy it first with @code{copy-sequence} and then sort.
 
-Sorting does not change the @sc{car}s of the cons cells in @var{list};
-each cons cell in the result contains the same element that it contained
-before.  The result differs from the argument @var{list} because the
-cells themselves have been reordered.
-
 Sorting does not change the @sc{car}s of the cons cells in @var{list};
 the cons cell that originally contained the element @code{a} in
 @var{list} still has @code{a} in its @sc{car} after sorting, but it now
@@ -1054,7 +1030,7 @@ long as you don't mind having duplicate elements).  Other useful
 functions for sets include @code{memq} and @code{delq}, and their
 @code{equal} versions, @code{member} and @code{delete}.
 
-@cindex CL note---lack @code{union}, @code{set}
+@cindex CL note---lack @code{union}, @code{intersection}
 @quotation
 @b{Common Lisp note:} Common Lisp has functions @code{union} (which
 avoids duplicate elements) and @code{intersection} for set operations,
@@ -1118,16 +1094,16 @@ sample-list
 @end group
 @group
 (delq 'c sample-list)
-     @result{} (a c (4))
+     @result{} (a b (4))
 @end group
 @group
 sample-list
-     @result{} (a c (4))
+     @result{} (a b (4))
 @end group
 @end example
 
-Note that @code{(delq 'b sample-list)} modifies @code{sample-list} to
-splice out the second element, but @code{(delq 'a sample-list)} does not
+Note that @code{(delq 'c sample-list)} modifies @code{sample-list} to
+splice out the third element, but @code{(delq 'a sample-list)} does not
 splice anything---it just returns a shorter list.  Don't assume that a
 variable which formerly held the argument @var{list} now has fewer
 elements, or that it still holds the original list!  Instead, save the
@@ -1187,7 +1163,7 @@ it removes the element just as @code{delq} would.  For example:
 @example
 @group
 (delete '(2) '((2) (1) (2)))
-     @result{} '((1))
+     @result{} ((1))
 @end group
 @end example
 @end defun
@@ -1198,6 +1174,9 @@ GNU Emacs Lisp are derived from Maclisp, not Common Lisp.  The Common
 Lisp versions do not use @code{equal} to compare elements.
 @end quotation
 
+  See also the function @code{add-to-list}, in @ref{Setting Variables},
+for another way to add an element to a list stored in a variable.
+
 @node Association Lists
 @section Association Lists
 @cindex association list
@@ -1303,6 +1282,16 @@ Here is another example, in which the keys and values are not symbols:
 @end smallexample
 @end defun
 
+@defun rassoc value alist
+This function returns the first association with value @var{value} in
+@var{alist}.  It returns @code{nil} if no association in @var{alist} has
+a @sc{cdr} @code{equal} to @var{value}.
+
+@code{rassoc} is like @code{assoc} except that it compares the @sc{cdr} of
+each @var{alist} association instead of the @sc{car}.  You can think of
+this as ``reverse @code{assoc}'', finding the key for a given value.
+@end defun
+
 @defun assq key alist
 This function is like @code{assoc} in that it returns the first
 association for @var{key} in @var{alist}, but it makes the comparison
@@ -1384,6 +1373,7 @@ the new alist without changing the old one.
 (setq needles-per-cluster
       '((2 . ("Austrian Pine" "Red Pine"))
         (3 . ("Pitch Pine"))
+@end group
         (5 . ("White Pine"))))
 @result{}
 ((2 "Austrian Pine" "Red Pine")
@@ -1404,6 +1394,7 @@ the new alist without changing the old one.
      @result{} nil
 (cdr (car (cdr needles-per-cluster)))
      @result{} ("Pitch Pine")
+@group
 (eq (cdr (car (cdr needles-per-cluster)))
     (cdr (car (cdr copy))))
      @result{} t
@@ -1415,8 +1406,7 @@ the associations of one copy without affecting the other:
 
 @smallexample
 @group
-(setcdr (assq 3 needles-per-cluster)
-        '("Martian Vacuum Pine"))
+(setcdr (assq 3 copy) '("Martian Vacuum Pine"))
 (cdr (assq 3 needles-per-cluster))
      @result{} ("Pitch Pine")
 @end group