Function: seq-do-indexed

seq-do-indexed is a byte-compiled function defined in seq.el.gz.

Signature

(seq-do-indexed FUNCTION SEQUENCE)

Documentation

Apply FUNCTION to each element of SEQUENCE and return nil.

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-do-indexed (lambda (a index) (message "%s:%s" index a)) '("foo" "bar"))
    e.g. => nil

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/seq.el.gz
(defun seq-do-indexed (function sequence)
  "Apply FUNCTION to each element of SEQUENCE and return nil.
Unlike `seq-map', FUNCTION takes two arguments: the element of
the sequence, and its index within the sequence."
  (let ((index 0))
    (seq-do (lambda (elt)
              (funcall function elt index)
              (setq index (1+ index)))
            sequence))
  nil)