Function: mapcar
mapcar is a function defined in fns.c.
Signature
(mapcar FUNCTION SEQUENCE)
Documentation
Apply FUNCTION to each element of SEQUENCE, and make a list of the results.
The result is a list just as long as SEQUENCE. SEQUENCE may be a list, a vector, a bool-vector, or a string.
Other relevant functions are documented in the vector, list and string groups.
Probably introduced at or before Emacs version 1.4.
Shortdoc
;; string
(mapcar #'identity "123")
=> (49 50 51)
;; list
(mapcar #'list '(1 2 3))
=> ((1) (2) (3))
;; vector
(mapcar #'identity [1 2 3])
=> (1 2 3)
Aliases
Source Code
// Defined in /usr/src/emacs/src/fns.c
{
USE_SAFE_ALLOCA;
EMACS_INT leni = XFIXNAT (Flength (sequence));
if (CHAR_TABLE_P (sequence))
wrong_type_argument (Qlistp, sequence);
Lisp_Object *args;
SAFE_ALLOCA_LISP (args, leni);
ptrdiff_t nmapped = mapcar1 (leni, args, function, sequence);
Lisp_Object ret = Flist (nmapped, args);
SAFE_FREE ();
return ret;
}