mapc
mapというよりforEachで副作用を起こすのに使う。戻り値は渡したシーケンス自体になる。
code: fns.c
DEFUN ("mapc", Fmapc, Smapc, 2, 2, 0,
doc: /* Apply FUNCTION to each element of SEQUENCE for side effects only.
Unlike `mapcar', don't accumulate the results. Return SEQUENCE.
SEQUENCE may be a list, a vector, a bool-vector, or a string. */)
(Lisp_Object function, Lisp_Object sequence)
{
register EMACS_INT leni;
leni = XFIXNAT (Flength (sequence));
if (CHAR_TABLE_P (sequence))
wrong_type_argument (Qlistp, sequence);
mapcar1 (leni, 0, function, sequence);
return sequence;
}
code: example.el
(mapc (lambda (x) (message "value: %c" x)) "123")
;; => > value: 1
;; => > value: 2
;; => > value: 3
;; => "123"
(mapc (lambda (x) (message "value: %s" x)) '(1 2 3))
;; => > value: 1
;; => > value: 2
;; => > value: 3
;; => (1 2 3)