chickadee » i3 » filter-containers

filter-containers predicate treeprocedure

Returns a list containing all containers for which the given predicate returns #t.

predicate
Predicate which is evaluated for each i3 container. Only containers for which the predicate returns #t are included in the return list
tree
(Part of) a list of containers as returned by (tree).
(define (filter-containers predicate tree)
  (if (null? tree)
    '()
    (append
      (if (predicate tree) (list tree) (list))
      (apply append
             (filter-map
               (lambda (node) (filter-containers predicate node))
               (cdr (assoc 'nodes tree)))))))