diff options
| author | Nicolas Petton | 2015-09-13 16:18:24 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2015-09-21 11:48:55 +0200 |
| commit | 0a893f0cfa166d7f17d982c3f0503dff2be25f62 (patch) | |
| tree | cdb172d4889e26e5502fee4dbbe5f3af1d5ebc57 | |
| parent | e2f0dd2f49d8638d20615bfa38e95a71202dd543 (diff) | |
| download | emacs-0a893f0cfa166d7f17d982c3f0503dff2be25f62.tar.gz emacs-0a893f0cfa166d7f17d982c3f0503dff2be25f62.zip | |
Better docstring and parameter name for seq-find
* lisp/emacs-lisp/seq.el (seq-find): Improve the docstring and rename
the parameter `sentinel' to `default'.
* doc/lispref/sequences.texi (Sequence Functions): Update the
documentation for `seq-find' accordingly.
| -rw-r--r-- | doc/lispref/sequences.texi | 9 | ||||
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 12 |
2 files changed, 10 insertions, 11 deletions
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi index 6292c02a21d..b85d5d4c1b1 100644 --- a/doc/lispref/sequences.texi +++ b/doc/lispref/sequences.texi | |||
| @@ -578,15 +578,14 @@ value is the value returned by @var{predicate}. | |||
| 578 | @end example | 578 | @end example |
| 579 | @end defun | 579 | @end defun |
| 580 | 580 | ||
| 581 | @defun seq-find predicate sequence &optional sentinel | 581 | @defun seq-find predicate sequence &optional default |
| 582 | This function returns the first element for which @var{predicate} | 582 | This function returns the first element for which @var{predicate} |
| 583 | returns non-@code{nil} in @var{sequence}. If no element matches | 583 | returns non-@code{nil} in @var{sequence}. If no element matches |
| 584 | @var{predicate}, @var{sentinel} is returned if non-@code{nil}, | 584 | @var{predicate}, @var{default} is returned. |
| 585 | @code{nil} otherwise. | ||
| 586 | 585 | ||
| 587 | Note that this function has an ambiguity if the found element is | 586 | Note that this function has an ambiguity if the found element is |
| 588 | @code{nil}, and if no @var{sentinel} is specified, as it cannot be | 587 | identical to @var{default}, as it cannot be known if an element was |
| 589 | known if an element was found or not. | 588 | found or not. |
| 590 | 589 | ||
| 591 | @example | 590 | @example |
| 592 | @group | 591 | @group |
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 4b50a0a9b7b..e0f17c0335d 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el | |||
| @@ -270,18 +270,18 @@ If so, return the non-nil value returned by PRED." | |||
| 270 | (throw 'seq--break result)))) | 270 | (throw 'seq--break result)))) |
| 271 | nil)) | 271 | nil)) |
| 272 | 272 | ||
| 273 | (cl-defgeneric seq-find (pred seq &optional sentinel) | 273 | (cl-defgeneric seq-find (pred seq &optional default) |
| 274 | "Return the first element for which (PRED element) is non-nil in SEQ. | 274 | "Return the first element for which (PRED element) is non-nil in SEQ. |
| 275 | If no element is found, return SENTINEL or nil. | 275 | If no element is found, return DEFAULT. |
| 276 | 276 | ||
| 277 | Note that `seq-find' has an ambiguity if the found element is nil | 277 | Note that `seq-find' has an ambiguity if the found element is |
| 278 | and if no SENTINEL is specified, as it cannot be known if an | 278 | identical to DEFAULT, as it cannot be known if an element was |
| 279 | element was found or not." | 279 | found or not." |
| 280 | (catch 'seq--break | 280 | (catch 'seq--break |
| 281 | (seq-doseq (elt seq) | 281 | (seq-doseq (elt seq) |
| 282 | (when (funcall pred elt) | 282 | (when (funcall pred elt) |
| 283 | (throw 'seq--break elt))) | 283 | (throw 'seq--break elt))) |
| 284 | sentinel)) | 284 | default)) |
| 285 | 285 | ||
| 286 | (cl-defgeneric seq-count (pred seq) | 286 | (cl-defgeneric seq-count (pred seq) |
| 287 | "Return the number of elements for which (PRED element) is non-nil in SEQ." | 287 | "Return the number of elements for which (PRED element) is non-nil in SEQ." |