Function: seq-find

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

Signature

(seq-find PRED SEQUENCE &optional DEFAULT)

Documentation

Return the first element in SEQUENCE for which PRED returns non-nil.

If no such element is found, return DEFAULT.

Note that seq-find has an ambiguity if the found element is identical to DEFAULT, as in that case it is impossible to know whether an element was found or not.

This does not modify SEQUENCE.

Other relevant functions are documented in the sequence group.

View in manual

Shortdoc

;; sequence
(seq-find #'numberp '(a b 3 4 f 6))
    => 3

Aliases

shadow-find (obsolete since 28.1)

Implementations

(seq-find PRED SEQUENCE &optional DEFAULT) in `seq.el'.

Undocumented

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/seq.el.gz
;;;###autoload
(cl-defgeneric seq-find (pred sequence &optional default)
  "Return the first element in SEQUENCE for which PRED returns non-nil.
If no such element is found, return DEFAULT.

Note that `seq-find' has an ambiguity if the found element is
identical to DEFAULT, as in that case it is impossible to know
whether an element was found or not.

This does not modify SEQUENCE."
  (catch 'seq--break
    (seq-doseq (elt sequence)
      (when (funcall pred elt)
        (throw 'seq--break elt)))
    default))