emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/dash a6e1436 124/316: Add -common-suffix


From: ELPA Syncer
Subject: [elpa] externals/dash a6e1436 124/316: Add -common-suffix
Date: Mon, 15 Feb 2021 15:57:40 -0500 (EST)

branch: externals/dash
commit a6e143682f7f75896b7383b408f492c9a7726df4
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Add -common-suffix
    
    Update -common-prefix tests along with those of -common-suffix.
---
 dash.el         |  5 +++++
 dev/examples.el | 17 ++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/dash.el b/dash.el
index 8d1d9a6..08924e2 100644
--- a/dash.el
+++ b/dash.el
@@ -2310,6 +2310,10 @@ or with `-compare-fn' if that's non-nil."
   (--reduce (--take-while (and acc (equal (pop acc) it)) it)
             lists))
 
+(defun -common-suffix (&rest lists)
+  "Return the longest common suffix of LISTS."
+  (nreverse (apply #'-common-prefix (mapcar #'reverse lists))))
+
 (defun -contains? (list element)
   "Return non-nil if LIST contains ELEMENT.
 
@@ -2904,6 +2908,7 @@ structure such as plist or alist."
                              "-inits"
                              "-tails"
                              "-common-prefix"
+                             "-common-suffix"
                              "-contains?"
                              "-contains-p"
                              "-same-items?"
diff --git a/dev/examples.el b/dev/examples.el
index 05669e9..43c0ace 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -389,13 +389,28 @@ new list."
 
   (defexamples -common-prefix
     (-common-prefix '(1)) => '(1)
-    (-common-prefix '(1 2) () '(1 2)) => ()
+    (-common-prefix '(1 2) '(3 4) '(1 2)) => ()
     (-common-prefix '(1 2) '(1 2 3) '(1 2 3 4)) => '(1 2)
+    (-common-prefix () '(1 2) '(1 2)) => ()
+    (-common-prefix '(1 2) '(1 2) ()) => ()
+    (-common-prefix '(1) '(1)) => '(1)
     (-common-prefix '(())) => '(())
     (-common-prefix () ()) => ()
     (-common-prefix ()) => ()
     (-common-prefix) => ())
 
+  (defexamples -common-suffix
+    (-common-suffix '(1)) => '(1)
+    (-common-suffix '(1 2) '(3 4) '(1 2)) => ()
+    (-common-suffix '(1 2 3 4) '(2 3 4) '(3 4)) => '(3 4)
+    (-common-suffix () '(1 2) '(1 2)) => ()
+    (-common-suffix '(1 2) '(1 2) ()) => ()
+    (-common-suffix '(1) '(1)) => '(1)
+    (-common-suffix '(())) => '(())
+    (-common-suffix () ()) => ()
+    (-common-suffix ()) => ()
+    (-common-suffix) => ())
+
   (defexamples -min
     (-min '(0)) => 0
     (-min '(3 2 1)) => 1



reply via email to

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