draw-tree.el
Draw tree structure of cons cells.
Ported to Emacs Lisp from Nils M Holm’s Scheme 9 from Empty Space’s Function Library (http://www.t3x.org/s9fes/draw-tree.scm.html) and its Common Lisp port written by CBaggers (https://github.com/cbaggers/draw-cons-tree).
Giulio Pietroiusti, 2022 Placed in the Public Domain.
Example:
(draw-tree '((a) (b . c) (d e))) ;; ==>
;; "
;; [o|o]---[o|o]---[o|/]
;; | | |
;; [o|/] | [o|o]---[o|/]
;; | | | |
;; a | d e
;; |
;; [o|o]--- c
;; |
;; b
;; "
See also:
- GNU Emacs Manual, Drawing Lists as Box Diagrams
- SICP, box-and-pointer notation
- amno1’s draw-cons-tree. (Analogous port, slightly different in that it inserts the result in the buffer as a side effect, rather than returning it. It allows to draw lines with unicode. Discovered after I wrote mine.)
- pair-tree.el