mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-19 02:10:10 +00:00
Rename seq-some-p to seq-some and seq-contains-p to seq-contains
* lisp/emacs-lisp/seq.el (seq-some, seq-contains): Rename the functions without the "-p" prefix. * test/automated/seq-tests.el (test-seq-some, test-seq-contains): Update the tests accordingly. * doc/lispref/sequences.texi (Sequence Functions): Update the documentation for seq.el.
This commit is contained in:
parent
b8147621ec
commit
c36663d866
3 changed files with 30 additions and 30 deletions
|
@ -252,14 +252,6 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called."
|
|||
(setq acc (funcall function acc elt)))
|
||||
acc)))
|
||||
|
||||
(cl-defgeneric seq-some-p (pred seq)
|
||||
"Return any element for which (PRED element) is non-nil in SEQ, nil otherwise."
|
||||
(catch 'seq--break
|
||||
(seq-doseq (elt seq)
|
||||
(when (funcall pred elt)
|
||||
(throw 'seq--break elt)))
|
||||
nil))
|
||||
|
||||
(cl-defgeneric seq-every-p (pred seq)
|
||||
"Return non-nil if (PRED element) is non-nil for all elements of the sequence SEQ."
|
||||
(catch 'seq--break
|
||||
|
@ -268,6 +260,14 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called."
|
|||
(throw 'seq--break nil)))
|
||||
t))
|
||||
|
||||
(cl-defgeneric seq-some (pred seq)
|
||||
"Return any element for which (PRED element) is non-nil in SEQ, nil otherwise."
|
||||
(catch 'seq--break
|
||||
(seq-doseq (elt seq)
|
||||
(when (funcall pred elt)
|
||||
(throw 'seq--break elt)))
|
||||
nil))
|
||||
|
||||
(cl-defgeneric seq-count (pred seq)
|
||||
"Return the number of elements for which (PRED element) is non-nil in SEQ."
|
||||
(let ((count 0))
|
||||
|
@ -276,10 +276,10 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called."
|
|||
(setq count (+ 1 count))))
|
||||
count))
|
||||
|
||||
(cl-defgeneric seq-contains-p (seq elt &optional testfn)
|
||||
(cl-defgeneric seq-contains (seq elt &optional testfn)
|
||||
"Return the first element in SEQ that equals to ELT.
|
||||
Equality is defined by TESTFN if non-nil or by `equal' if nil."
|
||||
(seq-some-p (lambda (e)
|
||||
(seq-some (lambda (e)
|
||||
(funcall (or testfn #'equal) elt e))
|
||||
seq))
|
||||
|
||||
|
@ -288,7 +288,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil."
|
|||
TESTFN is used to compare elements, or `equal' if TESTFN is nil."
|
||||
(let ((result '()))
|
||||
(seq-doseq (elt seq)
|
||||
(unless (seq-contains-p result elt testfn)
|
||||
(unless (seq-contains result elt testfn)
|
||||
(setq result (cons elt result))))
|
||||
(nreverse result)))
|
||||
|
||||
|
@ -313,7 +313,7 @@ negative integer or 0, nil is returned."
|
|||
"Return a list of the elements that appear in both SEQ1 and SEQ2.
|
||||
Equality is defined by TESTFN if non-nil or by `equal' if nil."
|
||||
(seq-reduce (lambda (acc elt)
|
||||
(if (seq-contains-p seq2 elt testfn)
|
||||
(if (seq-contains seq2 elt testfn)
|
||||
(cons elt acc)
|
||||
acc))
|
||||
(seq-reverse seq1)
|
||||
|
@ -323,7 +323,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil."
|
|||
"Return a list of the elements that appear in SEQ1 but not in SEQ2.
|
||||
Equality is defined by TESTFN if non-nil or by `equal' if nil."
|
||||
(seq-reduce (lambda (acc elt)
|
||||
(if (not (seq-contains-p seq2 elt testfn))
|
||||
(if (not (seq-contains seq2 elt testfn))
|
||||
(cons elt acc)
|
||||
acc))
|
||||
(seq-reverse seq1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue