diff options
| author | Nicolas Petton | 2015-09-06 00:05:52 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2015-09-06 00:05:52 +0200 |
| commit | c36663d866e64fcb4b0d94742009d84366e9b54f (patch) | |
| tree | 6ff19468ec463376c8ef05f14923c4220f0247b5 /lisp | |
| parent | b8147621ec91e1ce8e34d55141bb75921dbfc080 (diff) | |
| download | emacs-c36663d866e64fcb4b0d94742009d84366e9b54f.tar.gz emacs-c36663d866e64fcb4b0d94742009d84366e9b54f.zip | |
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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index a17b0a8f1b9..bf5495baac3 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el | |||
| @@ -252,14 +252,6 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called." | |||
| 252 | (setq acc (funcall function acc elt))) | 252 | (setq acc (funcall function acc elt))) |
| 253 | acc))) | 253 | acc))) |
| 254 | 254 | ||
| 255 | (cl-defgeneric seq-some-p (pred seq) | ||
| 256 | "Return any element for which (PRED element) is non-nil in SEQ, nil otherwise." | ||
| 257 | (catch 'seq--break | ||
| 258 | (seq-doseq (elt seq) | ||
| 259 | (when (funcall pred elt) | ||
| 260 | (throw 'seq--break elt))) | ||
| 261 | nil)) | ||
| 262 | |||
| 263 | (cl-defgeneric seq-every-p (pred seq) | 255 | (cl-defgeneric seq-every-p (pred seq) |
| 264 | "Return non-nil if (PRED element) is non-nil for all elements of the sequence SEQ." | 256 | "Return non-nil if (PRED element) is non-nil for all elements of the sequence SEQ." |
| 265 | (catch 'seq--break | 257 | (catch 'seq--break |
| @@ -268,6 +260,14 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called." | |||
| 268 | (throw 'seq--break nil))) | 260 | (throw 'seq--break nil))) |
| 269 | t)) | 261 | t)) |
| 270 | 262 | ||
| 263 | (cl-defgeneric seq-some (pred seq) | ||
| 264 | "Return any element for which (PRED element) is non-nil in SEQ, nil otherwise." | ||
| 265 | (catch 'seq--break | ||
| 266 | (seq-doseq (elt seq) | ||
| 267 | (when (funcall pred elt) | ||
| 268 | (throw 'seq--break elt))) | ||
| 269 | nil)) | ||
| 270 | |||
| 271 | (cl-defgeneric seq-count (pred seq) | 271 | (cl-defgeneric seq-count (pred seq) |
| 272 | "Return the number of elements for which (PRED element) is non-nil in SEQ." | 272 | "Return the number of elements for which (PRED element) is non-nil in SEQ." |
| 273 | (let ((count 0)) | 273 | (let ((count 0)) |
| @@ -276,10 +276,10 @@ If SEQ is empty, return INITIAL-VALUE and FUNCTION is not called." | |||
| 276 | (setq count (+ 1 count)))) | 276 | (setq count (+ 1 count)))) |
| 277 | count)) | 277 | count)) |
| 278 | 278 | ||
| 279 | (cl-defgeneric seq-contains-p (seq elt &optional testfn) | 279 | (cl-defgeneric seq-contains (seq elt &optional testfn) |
| 280 | "Return the first element in SEQ that equals to ELT. | 280 | "Return the first element in SEQ that equals to ELT. |
| 281 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 281 | Equality is defined by TESTFN if non-nil or by `equal' if nil." |
| 282 | (seq-some-p (lambda (e) | 282 | (seq-some (lambda (e) |
| 283 | (funcall (or testfn #'equal) elt e)) | 283 | (funcall (or testfn #'equal) elt e)) |
| 284 | seq)) | 284 | seq)) |
| 285 | 285 | ||
| @@ -288,7 +288,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." | |||
| 288 | TESTFN is used to compare elements, or `equal' if TESTFN is nil." | 288 | TESTFN is used to compare elements, or `equal' if TESTFN is nil." |
| 289 | (let ((result '())) | 289 | (let ((result '())) |
| 290 | (seq-doseq (elt seq) | 290 | (seq-doseq (elt seq) |
| 291 | (unless (seq-contains-p result elt testfn) | 291 | (unless (seq-contains result elt testfn) |
| 292 | (setq result (cons elt result)))) | 292 | (setq result (cons elt result)))) |
| 293 | (nreverse result))) | 293 | (nreverse result))) |
| 294 | 294 | ||
| @@ -313,7 +313,7 @@ negative integer or 0, nil is returned." | |||
| 313 | "Return a list of the elements that appear in both SEQ1 and SEQ2. | 313 | "Return a list of the elements that appear in both SEQ1 and SEQ2. |
| 314 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 314 | Equality is defined by TESTFN if non-nil or by `equal' if nil." |
| 315 | (seq-reduce (lambda (acc elt) | 315 | (seq-reduce (lambda (acc elt) |
| 316 | (if (seq-contains-p seq2 elt testfn) | 316 | (if (seq-contains seq2 elt testfn) |
| 317 | (cons elt acc) | 317 | (cons elt acc) |
| 318 | acc)) | 318 | acc)) |
| 319 | (seq-reverse seq1) | 319 | (seq-reverse seq1) |
| @@ -323,7 +323,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if nil." | |||
| 323 | "Return a list of the elements that appear in SEQ1 but not in SEQ2. | 323 | "Return a list of the elements that appear in SEQ1 but not in SEQ2. |
| 324 | Equality is defined by TESTFN if non-nil or by `equal' if nil." | 324 | Equality is defined by TESTFN if non-nil or by `equal' if nil." |
| 325 | (seq-reduce (lambda (acc elt) | 325 | (seq-reduce (lambda (acc elt) |
| 326 | (if (not (seq-contains-p seq2 elt testfn)) | 326 | (if (not (seq-contains seq2 elt testfn)) |
| 327 | (cons elt acc) | 327 | (cons elt acc) |
| 328 | acc)) | 328 | acc)) |
| 329 | (seq-reverse seq1) | 329 | (seq-reverse seq1) |