Function: seq-map-indexed
seq-map-indexed is a byte-compiled function defined in seq.el.gz.
Signature
(seq-map-indexed FUNCTION SEQUENCE)
Documentation
Return the result of applying FUNCTION to each element of SEQUENCE.
Unlike seq-map, FUNCTION takes two arguments: the element of
the sequence, and its index within the sequence.
Other relevant functions are documented in the sequence group.
Shortdoc
;; sequence
(seq-map-indexed (lambda (a i) (cons i a)) '(a b c))
=> ((0 . a) (1 . b) (2 . c))
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/seq.el.gz
(defun seq-map-indexed (function sequence)
"Return the result of applying FUNCTION to each element of SEQUENCE.
Unlike `seq-map', FUNCTION takes two arguments: the element of
the sequence, and its index within the sequence."
(let ((index 0))
(seq-map (lambda (elt)
(prog1
(funcall function elt index)
(setq index (1+ index))))
sequence)))