graph-to-tree.hlp 1.2 KB

123456789101112131415161718192021
  1. The function GRAPH-TO-TREE copies an arbitrary s-expression, removing
  2. cirularity. It does NOT show non-circular shared structure. Places
  3. where a substructure is EQ to one of its ancestors are replaced by
  4. non-interned id's of the form <n> where n is a small integer. The
  5. parent is replaced by a two element list of the form (<n>: u) where the
  6. n's match, and u is the (de-circularized) structure. This is most
  7. useful in adapting any printer for use with circular structures.
  8. The function CPRINT, also defined in the module GRAPH-TO-TREE, is
  9. simply (PRETTYPRINT (GRAPH-TO-TREE X)).
  10. Note that GRAPH-TO-TREE is very embryonic. It is MUCH more inefficient
  11. than it needs to be, heavily consing. A better implementation would
  12. use a stack (vector) instead of lists to hold intermediate expressions
  13. for comparison, and would not copy non-circular structure. In addition
  14. facilities should be added for optionally showing shared structure, for
  15. performing the inverse operation, and for also elliding long or deep
  16. structures. Finally, the output representation was chosen at random
  17. and can probably be improved, or at least brought in line with CL or
  18. some other standard.