]> code.delx.au - gnu-emacs/commitdiff
butlast, nbutlast.
authorDave Love <fx@gnu.org>
Fri, 5 Jan 2001 16:56:21 +0000 (16:56 +0000)
committerDave Love <fx@gnu.org>
Fri, 5 Jan 2001 16:56:21 +0000 (16:56 +0000)
etc/NEWS
lispref/lists.texi

index 385c811d8a164d9da557b4f36565e7dc74cec59c..0259fb2fa6e05f2e34a7f8f70c7019345a7eaf3e 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2105,6 +2105,10 @@ long promised.
 * Lisp changes made after edition 2.6 of the Emacs Lisp Manual,
 (Display-related features are described in a page of their own below.)
 
++++
+** Functions `butlast' and `nbutlast' for removing trailing elements
+from a list are now available without requiring the CL package.
+
 +++
 ** The new user-option `even-window-heights' can be set to nil
 to prevent `display-buffer' from evening out window heights.
index 222f723944f1d7e425fe273b80fac62575722dcf..6ae9e68d4025058b88bdc97348f14255a5ee809e 100644 (file)
@@ -422,6 +422,20 @@ This is the same as @code{(cdr (cdr @var{cons-cell}))}
 or @code{(nthcdr 2 @var{cons-cell})}.
 @end defun
 
+@defun butlast x &optional n
+This function returns the list @var{x} with the last element,
+or the last @var{n} elements, removed.  If @var{n} is greater
+than zero it makes a copy of the list so as not to damage the
+original list.  In general, @code{(append (butlast @var{x} @var{n})
+(last @var{x} @var{n}))} will return a list equal to @var{x}.
+@end defun
+
+@defun nbutlast x &optional n
+This is a version of @code{butlast} that works by destructively
+modifying the @code{cdr} of the appropriate element, rather than
+making a copy of the list.
+@end defun
+
 @node Building Lists
 @comment  node-name,  next,  previous,  up
 @section Building Cons Cells and Lists