aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Petton2015-09-28 21:11:05 +0200
committerNicolas Petton2015-09-28 21:15:58 +0200
commitf0b71429b9fbfb5dc5a561321de42a39fc176809 (patch)
tree221fcf3f39fb586596838b69517c60ab7be19563
parent5526561b0c8416cbae492bc246eacd30f7b1daa8 (diff)
downloademacs-f0b71429b9fbfb5dc5a561321de42a39fc176809.tar.gz
emacs-f0b71429b9fbfb5dc5a561321de42a39fc176809.zip
Better documentation for seq-some
* doc/lispref/sequences.texi: * lisp/emacs-lisp/seq.el: Update the documentation of seq-some to guarantee that the returned value is the first non-nil value that resulted from applying the predicate.
-rw-r--r--doc/lispref/sequences.texi9
-rw-r--r--lisp/emacs-lisp/seq.el3
2 files changed, 7 insertions, 5 deletions
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index b85d5d4c1b1..2dc494aec5d 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -558,9 +558,8 @@ calling @var{function}.
558@end defun 558@end defun
559 559
560@defun seq-some predicate sequence 560@defun seq-some predicate sequence
561 This function returns non-@code{nil} if @var{predicate} returns 561 This function returns the first non-@code{nil} value returned by
562non-@code{nil} for any element of @var{sequence}. If so, the returned 562applying @var{predicate} to each element of @var{sequence} in turn.
563value is the value returned by @var{predicate}.
564 563
565@example 564@example
566@group 565@group
@@ -575,6 +574,10 @@ value is the value returned by @var{predicate}.
575(seq-some #'null ["abc" 1 nil]) 574(seq-some #'null ["abc" 1 nil])
576@result{} t 575@result{} t
577@end group 576@end group
577@group
578(seq-some #'1+ [2 4 6])
579@result{} 3
580@end group
578@end example 581@end example
579@end defun 582@end defun
580 583
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index e0f17c0335d..a63447d3243 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -261,8 +261,7 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called."
261 t)) 261 t))
262 262
263(cl-defgeneric seq-some (pred seq) 263(cl-defgeneric seq-some (pred seq)
264 "Return non-nil if (PRED element) is non-nil for any element in SEQ, nil otherwise. 264 "Return the first value for which if (PRED element) is non-nil for in SEQ."
265If so, return the non-nil value returned by PRED."
266 (catch 'seq--break 265 (catch 'seq--break
267 (seq-doseq (elt seq) 266 (seq-doseq (elt seq)
268 (let ((result (funcall pred elt))) 267 (let ((result (funcall pred elt)))