chickadee » slib-wt-tree » wt-tree/for-each

wt-tree/for-each proc treeprocedure

Traverses tree in increasing order of key, applying proc to the key and value of each association. Any values returned by proc are ignored.

Provided proc runs in O(1) time, wt-tree/for-each takes time proportional to the size of tree.

(let ((t (alist->wt-tree string-wt-type
                         '(("rincewind" . 23)
                           ("twoflower" . 11)
                           ("the luggage" . 31))))
      (acc 0))
  (wt-tree/for-each (lambda (_k v)
                      (set! acc (+ v acc)))
                    t)
  acc)
; -> 65