Function: map-some

map-some is a byte-compiled function defined in map.el.gz.

Signature

(map-some PRED MAP)

Documentation

Return the first non-nil (PRED key val) in MAP.

Return nil if no such element is found. The default implementation delegates to map-do.

Implementations

(pred map) in `map.el'.

Undocumented

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/map.el.gz
(cl-defgeneric map-some (pred map)
  "Return the first non-nil (PRED key val) in MAP.
Return nil if no such element is found.
The default implementation delegates to `map-do'."
  ;; FIXME: Not sure if there's much benefit to defining it as defgeneric,
  ;; since as defined, I can't think of a map-type where we could provide an
  ;; algorithmically more efficient algorithm than the default.
  (catch 'map--break
    (map-do (lambda (key value)
              (let ((result (funcall pred key value)))
                (when result
                  (throw 'map--break result))))
            map)
    nil))