diff options
| author | Nicolas Petton <nicolas@petton.fr> | 2015-02-06 15:52:23 +0100 |
|---|---|---|
| committer | Nicolas Petton <nicolas@petton.fr> | 2015-02-06 15:52:23 +0100 |
| commit | 05211a578ed2c52f6ed818fc173561afbaea54c2 (patch) | |
| tree | 6070ecbed3f1c61b5d48886f06848308f8302ece /lisp | |
| parent | 5c9ad35f1e5fd8ee5561ef48baac1f6ff20ae679 (diff) | |
| download | emacs-05211a578ed2c52f6ed818fc173561afbaea54c2.tar.gz | |
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')
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/seq.el | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 32bbd2ccf3f..aa58c5349aa 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 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)) |
