Merge pull request #263 from basil-conto/blc/common-suffix

Add -common-suffix
master
Matus Goljer 8 years ago committed by GitHub
commit 1e22ef6a29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dash.el
  2. 17
      dev/examples.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?"

@ -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

Loading…
Cancel
Save