@end example
@end defun
+@defun seq-mapn function &rest sequences
+ This function returns the result of applying @var{function} to each
+element of @var{sequences}. The arity of @var{function} must match
+the number of sequences. Mapping stops at the shrotest sequence, and
+the returned value is a list.
+
+@example
+@group
+(seq-mapn #'+ '(2 4 6) '(20 40 60))
+@result{} (22 44 66)
+@end group
+@group
+(seq-mapn #'concat '("moskito" "bite") ["bee" "sting"])
+@result{} ("moskitobee" "bitesting")
+@end group
+@end example
+@end defun
+
@defun seq-filter predicate sequence
@cindex filtering sequences
This function returns a list of all the elements in @var{sequence}
;; Author: Nicolas Petton <nicolas@petton.fr>
;; Keywords: sequences
-;; Version: 2.1
+;; Version: 2.2
;; Package: seq
;; Maintainer: emacs-devel@gnu.org
(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.