Function: map-filter

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

Signature

(map-filter PRED MAP)

Documentation

Return an alist of key/val pairs for which (PRED key val) is non-nil in MAP.

The default implementation delegates to map-apply. This does not modify MAP.

Other relevant functions are documented in the map group.

Shortdoc

;; map
(map-filter (lambda (k _) (oddp k)) (list '(1 . 2) '(4 . 6)))
    => ((1 . 2))
  (map-filter (lambda (k v) (evenp (+ k v))) (list '(1 . 2) '(4 . 6)))
    => ((4 . 6))

Implementations

(map-filter PRED MAP) in `map.el'.

Undocumented

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/map.el.gz
(cl-defgeneric map-filter (pred map)
  "Return an alist of key/val pairs for which (PRED key val) is non-nil in MAP.
The default implementation delegates to `map-apply'.
This does not modify MAP."
  (delq nil (map-apply (lambda (key val)
                         (and (funcall pred key val)
                              (cons key val)))
                       map)))