diff options
| author | Glenn Morris | 2014-12-24 16:55:57 -0800 |
|---|---|---|
| committer | Glenn Morris | 2014-12-24 16:55:57 -0800 |
| commit | 218520e97c52bf43b82e9be1709b3462bf6627aa (patch) | |
| tree | 29534cea0f16f35509675e71a090c97c0652f25f /doc | |
| parent | 5306baa97b39ad28664a97bcf1fae0246dbcc2ff (diff) | |
| download | emacs-218520e97c52bf43b82e9be1709b3462bf6627aa.tar.gz emacs-218520e97c52bf43b82e9be1709b3462bf6627aa.zip | |
* doc/lispref/sequences.texi (Sequence Functions): Copyedits.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/ChangeLog | 2 | ||||
| -rw-r--r-- | doc/lispref/sequences.texi | 227 |
2 files changed, 77 insertions, 152 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 84654387dcd..56a073035cf 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 2014-12-25 Glenn Morris <rgm@gnu.org> | 1 | 2014-12-25 Glenn Morris <rgm@gnu.org> |
| 2 | 2 | ||
| 3 | * sequences.texi (Sequence Functions): Copyedits. | ||
| 4 | |||
| 3 | * control.texi (Pattern matching case statement): | 5 | * control.texi (Pattern matching case statement): |
| 4 | * positions.texi (List Motion): | 6 | * positions.texi (List Motion): |
| 5 | * streams.texi (Output Functions): | 7 | * streams.texi (Output Functions): |
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 8f8cfe72fa3..b1e315c7987 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi | |||
| @@ -217,14 +217,14 @@ y @result{} [foo (69 2)] | |||
| 217 | @end example | 217 | @end example |
| 218 | @end defun | 218 | @end defun |
| 219 | 219 | ||
| 220 | @defun reverse seq | 220 | @defun reverse sequence |
| 221 | @cindex string reverse | 221 | @cindex string reverse |
| 222 | @cindex list reverse | 222 | @cindex list reverse |
| 223 | @cindex vector reverse | 223 | @cindex vector reverse |
| 224 | @cindex sequence reverse | 224 | @cindex sequence reverse |
| 225 | This function creates a new sequence whose elements are the elements | 225 | This function creates a new sequence whose elements are the elements |
| 226 | of @var{seq}, but in reverse order. The original argument @var{seq} | 226 | of @var{sequence}, but in reverse order. The original argument @var{sequence} |
| 227 | is @emph{not} altered. Note that char-table cannot be reversed. | 227 | is @emph{not} altered. Note that char-tables cannot be reversed. |
| 228 | 228 | ||
| 229 | @example | 229 | @example |
| 230 | @group | 230 | @group |
| @@ -260,12 +260,12 @@ x | |||
| 260 | @end example | 260 | @end example |
| 261 | @end defun | 261 | @end defun |
| 262 | 262 | ||
| 263 | @defun nreverse seq | 263 | @defun nreverse sequence |
| 264 | @cindex reversing a string | 264 | @cindex reversing a string |
| 265 | @cindex reversing a list | 265 | @cindex reversing a list |
| 266 | @cindex reversing a vector | 266 | @cindex reversing a vector |
| 267 | This function reverses the order of the elements of @var{seq}. | 267 | This function reverses the order of the elements of @var{sequence}. |
| 268 | Unlike @code{reverse} the original @var{seq} may be modified. | 268 | Unlike @code{reverse} the original @var{sequence} may be modified. |
| 269 | 269 | ||
| 270 | For example: | 270 | For example: |
| 271 | 271 | ||
| @@ -421,22 +421,20 @@ useful example of @code{sort}. | |||
| 421 | 421 | ||
| 422 | @cindex sequence functions in seq | 422 | @cindex sequence functions in seq |
| 423 | @cindex seq library | 423 | @cindex seq library |
| 424 | The @file{seq} library provides the following additional sequence | 424 | The @file{seq.el} library provides the following additional sequence |
| 425 | manipulation macros and functions, prefixed with @code{seq-}. To use | 425 | manipulation macros and functions, prefixed with @code{seq-}. To use |
| 426 | them, you need to load the @file{seq} library first. | 426 | them, you must first load the @file{seq} library. |
| 427 | 427 | ||
| 428 | All functions defined in the @code{seq} library are free of | 428 | All functions defined in this library are free of side-effects; |
| 429 | side-effects, meaning that sequence(s) passed as argument(s) to | 429 | i.e., they do not modify any sequence (list, vector, or string) that |
| 430 | functions defined in @code{seq} are not modified. | 430 | you pass as an argument. Unless otherwise stated, the result is a |
| 431 | sequence of the same type as the input. For those functions that take | ||
| 432 | a predicate, this should be a function of one argument. | ||
| 431 | 433 | ||
| 432 | @defun seq-drop seq n | 434 | @defun seq-drop sequence n |
| 433 | This function returns a sequence of all but the first @var{n} | 435 | This function returns all but the first @var{n} (an integer) |
| 434 | elements of the sequence @var{seq}. | 436 | elements of @var{sequence}. If @var{n} is negative or zero, |
| 435 | 437 | the result is @var{sequence}. | |
| 436 | @var{seq} may be a list, vector or string and @var{n} must be an | ||
| 437 | integer. The result is the same type of sequence as @var{seq}. | ||
| 438 | |||
| 439 | If @var{n} is a negative integer or zero, @var{seq} is returned. | ||
| 440 | 438 | ||
| 441 | @example | 439 | @example |
| 442 | @group | 440 | @group |
| @@ -450,14 +448,10 @@ If @var{n} is a negative integer or zero, @var{seq} is returned. | |||
| 450 | @end example | 448 | @end example |
| 451 | @end defun | 449 | @end defun |
| 452 | 450 | ||
| 453 | @defun seq-take seq n | 451 | @defun seq-take sequence n |
| 454 | This function returns a sequence of the first @var{n} elements of | 452 | This function returns the first @var{n} (an integer) elements of |
| 455 | @var{seq}. | 453 | @var{sequence}. If @var{n} is negative or zero, the result |
| 456 | 454 | is @code{nil}. | |
| 457 | @var{seq} may be a list, vector or string and @var{n} must be an | ||
| 458 | integer. The result is the same type of sequence as @var{seq}. | ||
| 459 | |||
| 460 | If @var{n} is a negative integer or zero, an empty sequence is returned. | ||
| 461 | 455 | ||
| 462 | @example | 456 | @example |
| 463 | @group | 457 | @group |
| @@ -471,17 +465,9 @@ If @var{n} is a negative integer or zero, an empty sequence is returned. | |||
| 471 | @end example | 465 | @end example |
| 472 | @end defun | 466 | @end defun |
| 473 | 467 | ||
| 474 | @defun seq-take-while pred seq | 468 | @defun seq-take-while predicate sequence |
| 475 | This function returns a sub-sequence of the successive elements of | 469 | This function returns the members of @var{sequence} in order, |
| 476 | @var{seq} for which calling @code{pred} with that element returns | 470 | stopping before the first one for which @var{predicate} returns @code{nil}. |
| 477 | non-nil. | ||
| 478 | |||
| 479 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 480 | list, vector or string. The result is the same type of sequence as | ||
| 481 | @var{seq}. | ||
| 482 | |||
| 483 | If evaluating @var{pred} with the first element of @var{seq} as argument | ||
| 484 | returns @code{nil}, an empty sequence is returned. | ||
| 485 | 471 | ||
| 486 | @example | 472 | @example |
| 487 | @group | 473 | @group |
| @@ -495,17 +481,9 @@ returns @code{nil}, an empty sequence is returned. | |||
| 495 | @end example | 481 | @end example |
| 496 | @end defun | 482 | @end defun |
| 497 | 483 | ||
| 498 | @defun seq-drop-while pred seq | 484 | @defun seq-drop-while predicate sequence |
| 499 | This function returns a sub-sequence of @var{seq} from the first | 485 | This function returns the members of @var{sequence} in order, |
| 500 | element for which calling @var{pred} with that element returns | 486 | starting from the first one for which @var{predicate} returns @code{nil}. |
| 501 | @code{nil}. | ||
| 502 | |||
| 503 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 504 | list, vector or string. The result is the same type of sequence as | ||
| 505 | @var{seq}. | ||
| 506 | |||
| 507 | If evaluating @var{pred} with every element of @var{seq} returns | ||
| 508 | @code{nil}, @var{seq} is returned. | ||
| 509 | 487 | ||
| 510 | @example | 488 | @example |
| 511 | @group | 489 | @group |
| @@ -519,13 +497,10 @@ If evaluating @var{pred} with every element of @var{seq} returns | |||
| 519 | @end example | 497 | @end example |
| 520 | @end defun | 498 | @end defun |
| 521 | 499 | ||
| 522 | @defun seq-filter pred seq | 500 | @defun seq-filter predicate sequence |
| 523 | @cindex filtering sequences | 501 | @cindex filtering sequences |
| 524 | This function returns a list of all the elements in @var{seq} for | 502 | This function returns a list of all the elements in @var{sequence} |
| 525 | which calling @var{pred} with that element returns non-nil. | 503 | for which @var{predicate} returns non-@code{nil}. |
| 526 | |||
| 527 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 528 | list, vector or string. | ||
| 529 | 504 | ||
| 530 | @example | 505 | @example |
| 531 | @group | 506 | @group |
| @@ -539,13 +514,10 @@ list, vector or string. | |||
| 539 | @end example | 514 | @end example |
| 540 | @end defun | 515 | @end defun |
| 541 | 516 | ||
| 542 | @defun seq-remove pred seq | 517 | @defun seq-remove predicate sequence |
| 543 | @cindex removing from sequences | 518 | @cindex removing from sequences |
| 544 | This function returns a list of all the elements in @var{seq} for | 519 | This function returns a list of all the elements in @var{sequence} |
| 545 | which calling @var{pred} with that element returns @code{nil}. | 520 | for which @var{predicate} returns @code{nil}. |
| 546 | |||
| 547 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 548 | list, vector or string. | ||
| 549 | 521 | ||
| 550 | @example | 522 | @example |
| 551 | @group | 523 | @group |
| @@ -559,18 +531,15 @@ list, vector or string. | |||
| 559 | @end example | 531 | @end example |
| 560 | @end defun | 532 | @end defun |
| 561 | 533 | ||
| 562 | @defun seq-reduce function seq initial-value | 534 | @defun seq-reduce function sequence initial-value |
| 563 | @cindex reducing sequences | 535 | @cindex reducing sequences |
| 564 | This function returns the result of calling @var{function} with | 536 | This function returns the result of calling @var{function} with |
| 565 | @var{initial-value} and the first element of @var{seq}, then calling | 537 | @var{initial-value} and the first element of @var{sequence}, then calling |
| 566 | @var{function} with that result and the second element of @var{seq}, | 538 | @var{function} with that result and the second element of @var{sequence}, |
| 567 | then with that result and the third element of @var{seq}, etc. | 539 | then with that result and the third element of @var{sequence}, etc. |
| 568 | 540 | @var{function} should be a function of two arguments. If | |
| 569 | @var{function} must be a two-arguments function and @var{seq} may be a | 541 | @var{sequence} is empty, this returns @var{initial-value} without |
| 570 | list, vector or string. | 542 | calling @var{function}. |
| 571 | |||
| 572 | If @var{seq} is empty, @var{initial-value} is returned and | ||
| 573 | @var{function} is not called. | ||
| 574 | 543 | ||
| 575 | @example | 544 | @example |
| 576 | @group | 545 | @group |
| @@ -588,14 +557,9 @@ If @var{seq} is empty, @var{initial-value} is returned and | |||
| 588 | @end example | 557 | @end example |
| 589 | @end defun | 558 | @end defun |
| 590 | 559 | ||
| 591 | @defun seq-some-p pred seq | 560 | @defun seq-some-p predicate sequence |
| 592 | This function returns any element in @var{seq} for which calling | 561 | This function returns the first member of sequence for which @var{predicate} |
| 593 | @var{pred} with that element returns non-nil. If successively calling | 562 | returns non-@code{nil}. |
| 594 | @var{pred} with each element of @var{seq} always returns @code{nil}, | ||
| 595 | @code{nil} is returned. | ||
| 596 | |||
| 597 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 598 | list, vector or string. | ||
| 599 | 563 | ||
| 600 | @example | 564 | @example |
| 601 | @group | 565 | @group |
| @@ -609,12 +573,9 @@ list, vector or string. | |||
| 609 | @end example | 573 | @end example |
| 610 | @end defun | 574 | @end defun |
| 611 | 575 | ||
| 612 | @defun seq-every-p pred seq | 576 | @defun seq-every-p predicate sequence |
| 613 | This function returns non-nil if successively calling @var{pred} with | 577 | This function returns non-@code{nil} if applying @var{predicate} |
| 614 | each element of @var{seq} always returns non-nil, @code{nil} otherwise. | 578 | to every element of @var{sequence} returns non-@code{nil}. |
| 615 | |||
| 616 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 617 | list, vector or string. | ||
| 618 | 579 | ||
| 619 | @example | 580 | @example |
| 620 | @group | 581 | @group |
| @@ -628,11 +589,8 @@ list, vector or string. | |||
| 628 | @end example | 589 | @end example |
| 629 | @end defun | 590 | @end defun |
| 630 | 591 | ||
| 631 | @defun seq-empty-p seq | 592 | @defun seq-empty-p sequence |
| 632 | This function returns non-nil if the sequence @var{seq} is empty, | 593 | This function returns non-@code{nil} if @var{sequence} is empty. |
| 633 | @code{nil} otherwise. | ||
| 634 | |||
| 635 | @var{seq} may be a list, vector or string. | ||
| 636 | 594 | ||
| 637 | @example | 595 | @example |
| 638 | @group | 596 | @group |
| @@ -646,12 +604,9 @@ list, vector or string. | |||
| 646 | @end example | 604 | @end example |
| 647 | @end defun | 605 | @end defun |
| 648 | 606 | ||
| 649 | @defun seq-count pred seq | 607 | @defun seq-count predicate sequence |
| 650 | This function returns the number of elements in @var{seq} for which | 608 | This function returns the number of elements in @var{sequence} for which |
| 651 | calling @var{pred} with that element returns non-nil. | 609 | @var{predicate} returns non-@code{nil}. |
| 652 | |||
| 653 | @var{pred} must be a one-argument function and @var{seq} may be a | ||
| 654 | list, vector or string. | ||
| 655 | 610 | ||
| 656 | @example | 611 | @example |
| 657 | (seq-count (lambda (elt) (> elt 0)) [-1 2 0 3 -2]) | 612 | (seq-count (lambda (elt) (> elt 0)) [-1 2 0 3 -2]) |
| @@ -659,27 +614,17 @@ list, vector or string. | |||
| 659 | @end example | 614 | @end example |
| 660 | @end defun | 615 | @end defun |
| 661 | 616 | ||
| 662 | @defun seq-sort pred seq | ||
| 663 | This function returns a sorted sequence of the elements of | ||
| 664 | @var{seq}, comparing its elements with @var{pred}. Called with two | ||
| 665 | elements of @var{seq}, @var{pred} should return non-nil if the first | ||
| 666 | element should sort before the second. | ||
| 667 | |||
| 668 | @var{pred} must be a two-arguments function, @var{seq} may be a list, | ||
| 669 | vector or string. | ||
| 670 | |||
| 671 | The result is a sequence of the same type as SEQ. | ||
| 672 | @cindex sorting sequences | 617 | @cindex sorting sequences |
| 618 | @defun seq-sort function sequence | ||
| 619 | This function returns a copy of @var{sequence} that is sorted | ||
| 620 | according to @var{function}, a function of two arguments that returns | ||
| 621 | non-@code{nil} if the first argument should sort before the second. | ||
| 673 | @end defun | 622 | @end defun |
| 674 | 623 | ||
| 675 | @defun seq-contains-p seq elt testfn | 624 | @defun seq-contains-p sequence elt &optional function |
| 676 | This function returns the first element in @var{seq} that equals to | 625 | This function returns the first element in @var{sequence} that is equal to |
| 677 | @var{elt}. | 626 | @var{elt}. If the optional argument @var{function} is non-@code{nil}, |
| 678 | 627 | it is a function of two arguments to use instead of the default @code{equal}. | |
| 679 | Equality is defined by @var{testfn} if non-nil or by @code{equal} if | ||
| 680 | @code{nil}. | ||
| 681 | |||
| 682 | @var{seq} may be a list, vector or string. | ||
| 683 | 628 | ||
| 684 | @example | 629 | @example |
| 685 | @group | 630 | @group |
| @@ -694,13 +639,10 @@ Equality is defined by @var{testfn} if non-nil or by @code{equal} if | |||
| 694 | 639 | ||
| 695 | @end defun | 640 | @end defun |
| 696 | 641 | ||
| 697 | @defun seq-uniq seq testfn | 642 | @defun seq-uniq sequence &optional function |
| 698 | This function returns a list of the elements of @var{seq} with | 643 | This function returns a list of the elements of @var{sequence} with |
| 699 | duplicates removed. @var{testfn} is used to compare elements, or | 644 | duplicates removed. If the optional argument @var{function} is non-@code{nil}, |
| 700 | @code{equal} if @var{testfn} is @code{nil}. | 645 | it is a function of two arguments to use instead of the default @code{equal}. |
| 701 | |||
| 702 | @var{testfn} must be a two-argument function or @code{nil} and | ||
| 703 | @var{seq} may be a list, vector or string. | ||
| 704 | 646 | ||
| 705 | @example | 647 | @example |
| 706 | @group | 648 | @group |
| @@ -714,14 +656,11 @@ duplicates removed. @var{testfn} is used to compare elements, or | |||
| 714 | @end example | 656 | @end example |
| 715 | @end defun | 657 | @end defun |
| 716 | 658 | ||
| 717 | @defun seq-subseq seq start &optional end | 659 | @defun seq-subseq sequence start &optional end |
| 718 | This function returns a sub-sequence of @var{seq} from @var{start} | 660 | This function returns a subset of @var{sequence} from @var{start} |
| 719 | to @var{end}. If @var{end} is omitted, it default to the length of | 661 | to @var{end}, both integers (@var{end} defaults to the last element). |
| 720 | @var{seq}. If @var{start} or @var{end} is negative, it counts from | 662 | If @var{start} or @var{end} is negative, it counts from the end of |
| 721 | the end of @var{seq}. | 663 | @var{sequence}. |
| 722 | |||
| 723 | @var{seq} may be a list, vector or string. | ||
| 724 | The result is the same type of sequence as @var{seq}. | ||
| 725 | 664 | ||
| 726 | @example | 665 | @example |
| 727 | @group | 666 | @group |
| @@ -739,11 +678,10 @@ The result is the same type of sequence as @var{seq}. | |||
| 739 | @end example | 678 | @end example |
| 740 | @end defun | 679 | @end defun |
| 741 | 680 | ||
| 742 | @defun seq-concatenate type &rest seqs | 681 | @defun seq-concatenate type &rest sequences |
| 743 | This function returns a sequence made of the concatenation of | 682 | This function returns a sequence of type @var{type} made of the |
| 744 | @var{seqs}. The result is a sequence of type @var{type}. @var{type} | 683 | concatenation of @var{sequences}. @var{type} may be: @code{vector}, |
| 745 | may be one of the following symbols: @code{vector}, @code{list} or | 684 | @code{list} or @code{string}. |
| 746 | @code{string}. | ||
| 747 | 685 | ||
| 748 | @example | 686 | @example |
| 749 | @group | 687 | @group |
| @@ -757,26 +695,11 @@ may be one of the following symbols: @code{vector}, @code{list} or | |||
| 757 | @end example | 695 | @end example |
| 758 | @end defun | 696 | @end defun |
| 759 | 697 | ||
| 760 | @defmac seq-doseq (var seq [result]) body@dots{} | 698 | @defmac seq-doseq (var sequence [result]) body@dots{} |
| 761 | @cindex sequence iteration | 699 | @cindex sequence iteration |
| 762 | This macro is like @code{dolist}, except that @var{seq} can be a list, | 700 | This macro is like @code{dolist}, except that @var{sequence} can be a list, |
| 763 | vector or string (@pxref{Iteration} for more information about the | 701 | vector or string (@pxref{Iteration} for more information about the |
| 764 | @code{dolist} macro). | 702 | @code{dolist} macro). This is primarily useful for side-effects. |
| 765 | |||
| 766 | @var{seq-doseq} is primarily useful for side-effects. | ||
| 767 | |||
| 768 | @example | ||
| 769 | (seq-doseq (elt [1 2 3]) | ||
| 770 | (print (* 2 elt))) | ||
| 771 | @print{} | ||
| 772 | @print{} 2 | ||
| 773 | @print{} | ||
| 774 | @print{} 4 | ||
| 775 | @print{} | ||
| 776 | @print{} 6 | ||
| 777 | @result{} nil | ||
| 778 | |||
| 779 | @end example | ||
| 780 | @end defmac | 703 | @end defmac |
| 781 | 704 | ||
| 782 | @node Arrays | 705 | @node Arrays |