diff options
| author | Eli Zaretskii | 2024-09-23 14:41:34 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2024-09-23 14:41:34 +0300 |
| commit | c8ed48b9901790fdabcf91ef15a6ba47c96b48c8 (patch) | |
| tree | 846c960b3dd5d648768ca5efe4641314ff835318 | |
| parent | c1f2501f55d7454222389244512f732ac5e778b4 (diff) | |
| download | emacs-c8ed48b9901790fdabcf91ef15a6ba47c96b48c8.tar.gz emacs-c8ed48b9901790fdabcf91ef15a6ba47c96b48c8.zip | |
; Improve documentation of 'append'
* doc/lispref/lists.texi (Building Lists):
* src/fns.c (Fappend): Improve documentation of 'append'. (Bug#73427)
| -rw-r--r-- | doc/lispref/lists.texi | 24 | ||||
| -rw-r--r-- | src/fns.c | 7 |
2 files changed, 30 insertions, 1 deletions
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi index 6f4d838042a..816af4a4ff7 100644 --- a/doc/lispref/lists.texi +++ b/doc/lispref/lists.texi | |||
| @@ -668,6 +668,17 @@ This once was the usual way to copy a list, before the function | |||
| 668 | @end group | 668 | @end group |
| 669 | @end example | 669 | @end example |
| 670 | 670 | ||
| 671 | @cindex list of characters of a string | ||
| 672 | @cindex convert string to list of its characters | ||
| 673 | Here's how to convert a string into a list of its characters: | ||
| 674 | |||
| 675 | @example | ||
| 676 | @group | ||
| 677 | (append "abcd" nil) | ||
| 678 | @result{} (97 98 99 100) | ||
| 679 | @end group | ||
| 680 | @end example | ||
| 681 | |||
| 671 | With the help of @code{apply} (@pxref{Calling Functions}), we can append | 682 | With the help of @code{apply} (@pxref{Calling Functions}), we can append |
| 672 | all the lists in a list of lists: | 683 | all the lists in a list of lists: |
| 673 | 684 | ||
| @@ -690,10 +701,12 @@ all the lists in a list of lists: | |||
| 690 | Here are some examples where the final argument is not a list: | 701 | Here are some examples where the final argument is not a list: |
| 691 | 702 | ||
| 692 | @example | 703 | @example |
| 704 | @group | ||
| 693 | (append '(x y) 'z) | 705 | (append '(x y) 'z) |
| 694 | @result{} (x y . z) | 706 | @result{} (x y . z) |
| 695 | (append '(x y) [z]) | 707 | (append '(x y) [z]) |
| 696 | @result{} (x y . [z]) | 708 | @result{} (x y . [z]) |
| 709 | @end group | ||
| 697 | @end example | 710 | @end example |
| 698 | 711 | ||
| 699 | @noindent | 712 | @noindent |
| @@ -702,6 +715,17 @@ not a list, the sequence's elements do not become elements of the | |||
| 702 | resulting list. Instead, the sequence becomes the final @sc{cdr}, like | 715 | resulting list. Instead, the sequence becomes the final @sc{cdr}, like |
| 703 | any other non-list final argument. | 716 | any other non-list final argument. |
| 704 | 717 | ||
| 718 | As an exception, if all the arguments but the last are @code{nil} and | ||
| 719 | the last argument is not a list, the return value is that last argument | ||
| 720 | unchanged: | ||
| 721 | |||
| 722 | @example | ||
| 723 | @group | ||
| 724 | (append nil nil "abcd") | ||
| 725 | @result{} "abcd" | ||
| 726 | @end group | ||
| 727 | @end example | ||
| 728 | |||
| 705 | @defun copy-tree tree &optional vectors-and-records | 729 | @defun copy-tree tree &optional vectors-and-records |
| 706 | This function returns a copy of the tree @var{tree}. If @var{tree} is a | 730 | This function returns a copy of the tree @var{tree}. If @var{tree} is a |
| 707 | cons cell, this makes a new cons cell with the same @sc{car} and | 731 | cons cell, this makes a new cons cell with the same @sc{car} and |
| @@ -719,7 +719,12 @@ The result is a list whose elements are the elements of all the arguments. | |||
| 719 | Each argument may be a list, vector or string. | 719 | Each argument may be a list, vector or string. |
| 720 | 720 | ||
| 721 | All arguments except the last argument are copied. The last argument | 721 | All arguments except the last argument are copied. The last argument |
| 722 | is just used as the tail of the new list. | 722 | is just used as the tail of the new list. If the last argument is not |
| 723 | a list, this results in a dotted list. | ||
| 724 | |||
| 725 | As an exception, if all the arguments except the last are nil, and the | ||
| 726 | last argument is not a list, the return value is that last argument | ||
| 727 | unaltered. | ||
| 723 | 728 | ||
| 724 | usage: (append &rest SEQUENCES) */) | 729 | usage: (append &rest SEQUENCES) */) |
| 725 | (ptrdiff_t nargs, Lisp_Object *args) | 730 | (ptrdiff_t nargs, Lisp_Object *args) |