chickadee » i3 » descend-focused

descend-focused stop-predicate treeprocedure

Descends the focused containers of the given TREE, stopping at the first container which satisfies STOP-PREDICATE.

stop-predicate
Processing stops when this predicate first returns true. The return value is the container with which this predicate was evaluated.
tree
(Part of) a list of containers as returned by (tree).
(define (descend-focused stop-predicate tree)
  (if (stop-predicate tree)
    tree
    (if (null? (alist-ref 'focus tree))
      tree
      (descend-focused
        stop-predicate
        (let ((focused-id (first (alist-ref 'focus tree))))
          (find (lambda (con) (= (alist-ref 'id con) focused-id))
                (append
                  (alist-ref 'nodes tree)
                  (alist-ref 'floating_nodes tree))))))))