utilities.print-tree

API Reference

utilities.print-tree

This system provides simple facilities for printing tree structures.

UTILITIES.PRINT-TREE

This package provides functions for printing tree structures.

    The main entry point is the `print-tree' function. It accepts a
    stream, a tree object and a printer function.

    In common cases, tree printer functions can be creating using
    `make-node-printer' or `make-folding-node-printer'.
  • Variable *USE-UNICODE?*
    t
  • Function PRINT-TREE (stream root printer)
    Print the tree ROOT to STREAM using PRINTER. PRINTER is called with four arguments, STREAM, ROOT, the keyword :root and the integer 0, indicating depth zero. PRINTER will usually call `print-node', `print-subree' and `print-node-contents' to do the actual work. Functions suitable for use as PRINTER can, for many common cases, be constructed via `make-node-printer' and `make-folding-node-printer'.
  • Function PRINT-SUBTREE (stream nodes printer &optional final? (depth 0))
  • Function PRINT-NODE-CONTENTS (stream printer &optional final? (depth 0))
  • Function MAKE-NODE-PRINTER (first-line-printer rest-printer children)
    Return a node printer function that used FIRST-LINE-PRINTER, REST-PRINTER and CHILDREN. FIRST-LINE-PRINTER is called with the destination stream, the depth of the node and the node and should print a one-line representation of the node to the stream. The function should return true if REST-PRINTER should be called to print more details for the node. REST-PRINTER is also called with the destination stream, the depth of the node and node. It is not restricted to only producing a single line, however. CHILDREN is called with a node and must return a (possibly empty) list of children of the node.
  • Function MAKE-FOLDING-NODE-PRINTER (first-line-printer rest-printer children predicate)
    Like `make-node-printer', return a node printer function that used FIRST-LINE-PRINTER, REST-PRINTER and CHILDREN. PREDICATE is called to determine whether and to what extend nodes should be printed. When called with the depth of a node and node as its arguments, PREDICATE must return a list of "bits" of the node that should be printed. The following bits are recognized: :first Print first line of the node by calling FIRST-LINE-PRINTER? :content Print more details for the node by calling REST-PRINTER? :children Print children of the node? :children-ellipsis Print ellipsis of the form "?", if the node has children butlast the :children bit has not been specified? When PREDICATE returns T, all bits are printed.