mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-29 07:58:28 +00:00
Add seq-mapcat
* lisp/emacs-lisp/seq.el (seq-mapcat): New function * test/automated/seq-tests.el: Add unit tests for seq-mapcat
This commit is contained in:
parent
5c9ad35f1e
commit
05211a578e
@ -1,3 +1,7 @@
|
||||
2015-02-06 Nicolas Petton <nicolas@petton.fr>
|
||||
|
||||
* emacs-lisp/seq.el (seq-mapcat): New function.
|
||||
|
||||
2015-02-06 Artur Malabarba <bruce.connor.am@gmail.com>
|
||||
|
||||
* doc-view.el (doc-view-kill-proc-and-buffer): Obsolete. Use
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nicolas Petton <petton.nicolas@gmail.com>
|
||||
;; Author: Nicolas Petton <nicolas@petton.fr>
|
||||
;; Keywords: sequences
|
||||
;; Version: 1.0
|
||||
;; Version: 1.1
|
||||
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
||||
@ -224,6 +224,12 @@ TYPE must be one of following symbols: vector, string or list.
|
||||
(`list (apply #'append (append seqs '(nil))))
|
||||
(t (error "Not a sequence type name: %s" type))))
|
||||
|
||||
(defun seq-mapcat (function seq &optional type)
|
||||
"Concatenate the result of applying FUNCTION to each element of SEQ.
|
||||
The result is a sequence of type TYPE, or a list if TYPE is nil."
|
||||
(apply #'seq-concatenate (or type 'list)
|
||||
(seq-map function seq)))
|
||||
|
||||
(defun seq--drop-list (list n)
|
||||
"Optimized version of `seq-drop' for lists."
|
||||
(while (and list (> n 0))
|
||||
|
@ -1,3 +1,7 @@
|
||||
2015-02-02 Nicolas Petton <nicolas@petton.fr>
|
||||
|
||||
* automated/seq-tests.el: New test for seq-mapcat.
|
||||
|
||||
2015-02-05 Artur Malabarba <bruce.connor.am@gmail.com>
|
||||
|
||||
* automated/package-test.el (package-test-get-deps): Fix typo.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
|
||||
|
||||
;; Author: Nicolas Petton <petton.nicolas@gmail.com>
|
||||
;; Author: Nicolas Petton <nicolas@petton.fr>
|
||||
;; Maintainer: emacs-devel@gnu.org
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
@ -197,5 +197,13 @@ Evaluate BODY for each created sequence.
|
||||
(should (equal (seq-concatenate 'vector nil '(8 10)) [8 10]))
|
||||
(should (equal (seq-concatenate 'vector seq nil) [2 4 6]))))
|
||||
|
||||
(ert-deftest test-seq-mapcat ()
|
||||
(should (equal (seq-mapcat #'seq-reverse '((3 2 1) (6 5 4)))
|
||||
'(1 2 3 4 5 6)))
|
||||
(should (equal (seq-mapcat #'seq-reverse '[(3 2 1) (6 5 4)])
|
||||
'(1 2 3 4 5 6)))
|
||||
(should (equal (seq-mapcat #'seq-reverse '((3 2 1) (6 5 4)) 'vector)
|
||||
'[1 2 3 4 5 6])))
|
||||
|
||||
(provide 'seq-tests)
|
||||
;;; seq-tests.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user