Function: seq-positions

seq-positions is a byte-compiled function defined in seq-25.el.

Signature

(seq-positions SEQUENCE ELT &optional TESTFN)

Documentation

Return list of indices of SEQUENCE elements for which TESTFN returns non-nil.

TESTFN is a two-argument function which is called with each element of SEQUENCE as the first argument and ELT as the second. TESTFN defaults to equal.

The result is a list of (zero-based) indices.

Implementations

(sequence elt &optional testfn) in `seq-25.el'.

Undocumented

Source Code

;; Defined in ~/.emacs.d/elpa/seq-2.24/seq-25.el
;;;###autoload
(cl-defgeneric seq-positions (sequence elt &optional testfn)
  "Return list of indices of SEQUENCE elements for which TESTFN returns non-nil.

TESTFN is a two-argument function which is called with each element of
SEQUENCE as the first argument and ELT as the second.
TESTFN defaults to `equal'.

The result is a list of (zero-based) indices."
  (let ((result '()))
    (seq-do-indexed
     (lambda (e index)
       (when (funcall (or testfn #'equal) e elt)
         (push index result)))
     sequence)
    (nreverse result)))