emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c36663d 1/4: Rename seq-some-p to seq-some and seq-


From: Nicolas Petton
Subject: [Emacs-diffs] master c36663d 1/4: Rename seq-some-p to seq-some and seq-contains-p to seq-contains
Date: Sat, 05 Sep 2015 22:56:05 +0000

branch: master
commit c36663d866e64fcb4b0d94742009d84366e9b54f
Author: Nicolas Petton <address@hidden>
Commit: Nicolas Petton <address@hidden>

    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.
---
 doc/lispref/sequences.texi  |   14 +++++++-------
 lisp/emacs-lisp/seq.el      |   26 +++++++++++++-------------
 test/automated/seq-tests.el |   20 ++++++++++----------
 3 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 12ed881..22ae995 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -557,17 +557,17 @@ calling @var{function}.
 @end example
 @end defun
 
address@hidden seq-some-p predicate sequence
address@hidden seq-some predicate sequence
   This function returns the first member of sequence for which @var{predicate}
 returns address@hidden
 
 @example
 @group
-(seq-some-p #'numberp ["abc" 1 nil])
+(seq-some #'numberp ["abc" 1 nil])
 @result{} 1
 @end group
 @group
-(seq-some-p #'numberp ["abc" "def"])
+(seq-some #'numberp ["abc" "def"])
 @result{} nil
 @end group
 @end example
@@ -583,7 +583,7 @@ to every element of @var{sequence} returns address@hidden
 @result{} t
 @end group
 @group
-(seq-some-p #'numberp [2 4 "6"])
+(seq-some #'numberp [2 4 "6"])
 @result{} nil
 @end group
 @end example
@@ -621,18 +621,18 @@ according to @var{function}, a function of two arguments 
that returns
 address@hidden if the first argument should sort before the second.
 @end defun
 
address@hidden seq-contains-p sequence elt &optional function
address@hidden seq-contains sequence elt &optional function
   This function returns the first element in @var{sequence} that is equal to
 @var{elt}.  If the optional argument @var{function} is address@hidden,
 it is a function of two arguments to use instead of the default @code{equal}.
 
 @example
 @group
-(seq-contains-p '(symbol1 symbol2) 'symbol1)
+(seq-contains '(symbol1 symbol2) 'symbol1)
 @result{} symbol1
 @end group
 @group
-(seq-contains-p '(symbol1 symbol2) 'symbol3)
+(seq-contains '(symbol1 symbol2) 'symbol3)
 @result{} nil
 @end group
 @end example
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index a17b0a8..bf5495b 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."
         (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)
diff --git a/test/automated/seq-tests.el b/test/automated/seq-tests.el
index 482daee..efbb90d 100644
--- a/test/automated/seq-tests.el
+++ b/test/automated/seq-tests.el
@@ -129,21 +129,21 @@ Evaluate BODY for each created sequence.
     (should (eq (seq-reduce #'+ seq 0) 0))
     (should (eq (seq-reduce #'+ seq 7) 7))))
 
-(ert-deftest test-seq-some-p ()
+(ert-deftest test-seq-some ()
   (with-test-sequences (seq '(4 3 2 1))
-    (should (= (seq-some-p #'test-sequences-evenp seq) 4))
-    (should (= (seq-some-p #'test-sequences-oddp seq) 3))
-    (should-not (seq-some-p (lambda (elt) (> elt 10)) seq)))
+    (should (= (seq-some #'test-sequences-evenp seq) 4))
+    (should (= (seq-some #'test-sequences-oddp seq) 3))
+    (should-not (seq-some (lambda (elt) (> elt 10)) seq)))
   (with-test-sequences (seq '())
-    (should-not (seq-some-p #'test-sequences-oddp seq))))
+    (should-not (seq-some #'test-sequences-oddp seq))))
 
-(ert-deftest test-seq-contains-p ()
+(ert-deftest test-seq-contains ()
   (with-test-sequences (seq '(3 4 5 6))
-    (should (seq-contains-p seq 3))
-    (should-not (seq-contains-p seq 7)))
+    (should (seq-contains seq 3))
+    (should-not (seq-contains seq 7)))
   (with-test-sequences (seq '())
-    (should-not (seq-contains-p seq 3))
-    (should-not (seq-contains-p seq nil))))
+    (should-not (seq-contains seq 3))
+    (should-not (seq-contains seq nil))))
 
 (ert-deftest test-seq-every-p ()
   (with-test-sequences (seq '(43 54 22 1))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]