summaryrefslogtreecommitdiff
path: root/lispref
diff options
context:
space:
mode:
authorDave Love <fx@gnu.org>2001-01-05 16:56:21 +0000
committerDave Love <fx@gnu.org>2001-01-05 16:56:21 +0000
commit023045d66ddef29afa17245d4de14b9d77915f5a (patch)
tree3f8de79c7046ec9db6149ed39261c9b5e72524f5 /lispref
parent2d4c95097a4fb7601070751e9d444eb3bcad467a (diff)
downloademacs-023045d66ddef29afa17245d4de14b9d77915f5a.tar.gz
butlast, nbutlast.
Diffstat (limited to 'lispref')
-rw-r--r--lispref/lists.texi14
1 files changed, 14 insertions, 0 deletions
diff --git a/lispref/lists.texi b/lispref/lists.texi
index 222f723944f..6ae9e68d402 100644
--- a/lispref/lists.texi
+++ b/lispref/lists.texi
@@ -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