Function: cl-mapcar
cl-mapcar is a byte-compiled function defined in cl-lib.el.gz.
Signature
(cl-mapcar FUNCTION SEQ...)
Documentation
Apply FUNCTION to each element of SEQ, and make a list of the results.
If there are several SEQs, FUNCTION is called with that many arguments,
and mapping stops as soon as the shortest list runs out. With just one
SEQ, this is like mapcar. With several, it is like the Common Lisp
mapcar function extended to arbitrary sequence types.
Aliases
mapcar* (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-lib.el.gz
(defun cl-mapcar (func x &rest rest)
"Apply FUNCTION to each element of SEQ, and make a list of the results.
If there are several SEQs, FUNCTION is called with that many arguments,
and mapping stops as soon as the shortest list runs out. With just one
SEQ, this is like `mapcar'. With several, it is like the Common Lisp
`mapcar' function extended to arbitrary sequence types.
\n(fn FUNCTION SEQ...)"
(declare (important-return-value t))
(if rest
(if (or (cdr rest) (nlistp x) (nlistp (car rest)))
(cl--mapcar-many func (cons x rest) 'accumulate)
(let ((res nil) (y (car rest)))
(while (and x y)
(push (funcall func (pop x) (pop y)) res))
(nreverse res)))
(mapcar func x)))