diff options
| author | Paul Eggert | 2018-12-17 09:55:06 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-12-17 10:26:15 -0800 |
| commit | a5995a326d1dad9bccf1ad7eb96e4e8146f6dcbe (patch) | |
| tree | 12d89cba78255f1181cca879ffd36fa188bab774 /lisp | |
| parent | 8664ba18c7c56bc463f69dd5b131b4071612d567 (diff) | |
| download | emacs-a5995a326d1dad9bccf1ad7eb96e4e8146f6dcbe.tar.gz emacs-a5995a326d1dad9bccf1ad7eb96e4e8146f6dcbe.zip | |
Improve flatten-tree documentation
* doc/lispref/lists.texi (Building Lists):
* lisp/subr.el (flatten-tree):
Don’t imply that flatten-tree modifies its argument.
Clarify wording.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/subr.el | 14 |
1 files changed, 5 insertions, 9 deletions
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. |
| 5453 | This always returns a list containing all the terminal nodes, or | 5453 | In other words, return a list of the non-nil terminal nodes, or |
| 5454 | \"leaves\", of TREE. Dotted pairs are flattened as well, and nil | 5454 | leaves, of the tree of cons cells rooted at TREE. Leaves in the |
| 5455 | elements are removed. | 5455 | returned 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 | |||
| 5460 | TREE can be anything that can be made into a list. For each | ||
| 5461 | element in TREE, if it is a cons cell return its car | ||
| 5462 | recursively. 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))) |