aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/lists.texi10
-rw-r--r--lisp/subr.el14
2 files changed, 10 insertions, 14 deletions
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index 31cc3190854..0a1d5b5dc33 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -668,10 +668,10 @@ their elements).
668@end defun 668@end defun
669 669
670@defun flatten-tree tree 670@defun flatten-tree tree
671Take @var{tree} and "flatten" it. 671This function returns a ``flattened'' copy of @var{tree}, that is,
672This always returns a list containing all the terminal nodes, or 672a list containing all the non-@code{nil} terminal nodes, or leaves, of
673leaves, of @var{tree}. Dotted pairs are flattened as well, and nil 673the tree of cons cells rooted at @var{tree}. Leaves in the returned
674elements are removed. 674list are in the same order as in @var{tree}.
675@end defun 675@end defun
676 676
677@example 677@example
@@ -680,7 +680,7 @@ elements are removed.
680@end example 680@end example
681 681
682@defun number-sequence from &optional to separation 682@defun number-sequence from &optional to separation
683This returns a list of numbers starting with @var{from} and 683This function returns a list of numbers starting with @var{from} and
684incrementing by @var{separation}, and ending at or just before 684incrementing by @var{separation}, and ending at or just before
685@var{to}. @var{separation} can be positive or negative and defaults 685@var{to}. @var{separation} can be positive or negative and defaults
686to 1. If @var{to} is @code{nil} or numerically equal to @var{from}, 686to 1. If @var{to} is @code{nil} or numerically equal to @var{from},
diff --git a/lisp/subr.el b/lisp/subr.el
index 3dec6cf66c3..c5004a539b0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -5449,17 +5449,13 @@ This function is called from lisp/Makefile and leim/Makefile."
5449 file) 5449 file)
5450 5450
5451(defun flatten-tree (tree) 5451(defun flatten-tree (tree)
5452 "Take TREE and \"flatten\" it. 5452 "Return a \"flattened\" copy of TREE.
5453This always returns a list containing all the terminal nodes, or 5453In other words, return a list of the non-nil terminal nodes, or
5454\"leaves\", of TREE. Dotted pairs are flattened as well, and nil 5454leaves, of the tree of cons cells rooted at TREE. Leaves in the
5455elements are removed. 5455returned list are in the same order as in TREE.
5456 5456
5457\(flatten-tree \\='(1 (2 . 3) nil (4 5 (6)) 7)) 5457\(flatten-tree \\='(1 (2 . 3) nil (4 5 (6)) 7))
5458=> (1 2 3 4 5 6 7) 5458=> (1 2 3 4 5 6 7)"
5459
5460TREE can be anything that can be made into a list. For each
5461element in TREE, if it is a cons cell return its car
5462recursively. Otherwise return the element."
5463 (let (elems) 5459 (let (elems)
5464 (while (consp tree) 5460 (while (consp tree)
5465 (let ((elem (pop tree))) 5461 (let ((elem (pop tree)))