summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorNicolas Petton <nicolas@petton.fr>2015-02-06 15:52:23 +0100
committerNicolas Petton <nicolas@petton.fr>2015-02-06 15:52:23 +0100
commit05211a578ed2c52f6ed818fc173561afbaea54c2 (patch)
tree6070ecbed3f1c61b5d48886f06848308f8302ece /lisp/emacs-lisp
parent5c9ad35f1e5fd8ee5561ef48baac1f6ff20ae679 (diff)
downloademacs-05211a578ed2c52f6ed818fc173561afbaea54c2.tar.gz
emacs-05211a578ed2c52f6ed818fc173561afbaea54c2.tar.bz2
emacs-05211a578ed2c52f6ed818fc173561afbaea54c2.zip
Add seq-mapcat
* lisp/emacs-lisp/seq.el (seq-mapcat): New function * test/automated/seq-tests.el: Add unit tests for seq-mapcat
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/seq.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index b28153b7f81..bd234a3b55a 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -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))