diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-10-28 14:27:39 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-10-28 15:40:23 +0000 |
commit | 7dfe247864f12b93b906edb5934af3c356acade4 (patch) | |
tree | 49ecd679906aae8113b8381fe93b91ddde51b648 /lisp/emacs-lisp/seq.el | |
parent | 4281f722dd782d91f4b2bbd03834cbd1d944db5c (diff) | |
download | emacs-7dfe247864f12b93b906edb5934af3c356acade4.tar.gz emacs-7dfe247864f12b93b906edb5934af3c356acade4.tar.bz2 emacs-7dfe247864f12b93b906edb5934af3c356acade4.zip |
* lisp/emacs-lisp/seq.el (seq-mapn): New function
* doc/lispref/sequences.texi (Sequence Functions): Document seq-mapn
Diffstat (limited to 'lisp/emacs-lisp/seq.el')
-rw-r--r-- | lisp/emacs-lisp/seq.el | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index d0c2d24b015..68265094c17 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -4,7 +4,7 @@ ;; Author: Nicolas Petton <nicolas@petton.fr> ;; Keywords: sequences -;; Version: 2.1 +;; Version: 2.2 ;; Package: seq ;; Maintainer: emacs-devel@gnu.org @@ -148,6 +148,21 @@ if positive or too small if negative)." (cl-defmethod seq-map (function (sequence sequence)) (mapcar function sequence)) +(cl-defgeneric seq-mapn (function sequence &rest sequences) + "Like `seq-map' but FUNCTION is mapped over all SEQUENCES. +The arity of FUNCTION must match the number of SEQUENCES, and the +mapping stops on the shortest sequence. +Return a list of the results. + +\(fn FUNCTION SEQUENCES...)" + (let ((result nil) + (sequences (seq-map (lambda (s) (seq-into s 'list)) + (cons sequence sequences)))) + (while (not (memq nil sequences)) + (push (apply function (seq-map #'car sequences)) result) + (setq sequences (seq-map #'cdr sequences))) + (nreverse result))) + (cl-defgeneric seq-drop (sequence n) "Remove the first N elements of SEQUENCE and return the result. The result is a sequence of the same type as SEQUENCE. |