aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Petton2015-06-30 18:29:32 +0200
committerNicolas Petton2015-06-30 18:40:19 +0200
commitb1047c3b422f5280a9de6c56b1ba77e5dbc185ee (patch)
tree50386cf0758e757f6488a83e94af4f5fb0f84ad5
parent3bea77f65504ee7c4364c300fd1f7d699e2866ac (diff)
downloademacs-b1047c3b422f5280a9de6c56b1ba77e5dbc185ee.tar.gz
emacs-b1047c3b422f5280a9de6c56b1ba77e5dbc185ee.zip
Add seq-min and seq-max
Bump version number. * lisp/emacs-lisp/seq.el (seq-min, seq-max): New functions. * test/automated/seq-tests.el: Add tests for seq-min and seq-max.
-rw-r--r--lisp/emacs-lisp/seq.el12
-rw-r--r--test/automated/seq-tests.el5
2 files changed, 16 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index 2d20de61711..68d40b99f70 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Nicolas Petton <nicolas@petton.fr> 5;; Author: Nicolas Petton <nicolas@petton.fr>
6;; Keywords: sequences 6;; Keywords: sequences
7;; Version: 1.7 7;; Version: 1.8
8;; Package: seq 8;; Package: seq
9 9
10;; Maintainer: emacs-devel@gnu.org 10;; Maintainer: emacs-devel@gnu.org
@@ -325,6 +325,16 @@ TYPE can be one of the following symbols: vector, string or list."
325 (`list (append seq nil)) 325 (`list (append seq nil))
326 (_ (error "Not a sequence type name: %S" type)))) 326 (_ (error "Not a sequence type name: %S" type))))
327 327
328(defun seq-min (seq)
329 "Return the smallest element of SEQ.
330SEQ must be a sequence of numbers or markers."
331 (apply #'min (seq-into seq 'list)))
332
333(defun seq-max (seq)
334 "Return the largest element of SEQ.
335SEQ must be a sequence of numbers or markers."
336 (apply #'max (seq-into seq 'list)))
337
328(defun seq--drop-list (list n) 338(defun seq--drop-list (list n)
329 "Return a list from LIST without its first N elements. 339 "Return a list from LIST without its first N elements.
330This is an optimization for lists in `seq-drop'." 340This is an optimization for lists in `seq-drop'."
diff --git a/test/automated/seq-tests.el b/test/automated/seq-tests.el
index ab46eb85f76..3643ce53cb0 100644
--- a/test/automated/seq-tests.el
+++ b/test/automated/seq-tests.el
@@ -297,5 +297,10 @@ Evaluate BODY for each created sequence.
297 (should (null b)) 297 (should (null b))
298 (should (null c))))) 298 (should (null c)))))
299 299
300(ert-deftest test-seq-min-max ()
301 (with-test-sequences (seq '(4 5 3 2 0 4))
302 (should (= (seq-min seq) 0))
303 (should (= (seq-max seq) 5))))
304
300(provide 'seq-tests) 305(provide 'seq-tests)
301;;; seq-tests.el ends here 306;;; seq-tests.el ends here