draw-cons-tree
draw-cons-tree copied to clipboard
Handle shared structure if *PRINT-CIRCLE* is true
Currently:
CL-USER> (draw-cons-tree:draw-tree '(#1=(1 2 3) #1#))
[o|o]---[o|/]
| |
| [o|o]---[o|o]---[o|/]
| | | |
| 1 2 3
|
[o|o]---[o|o]---[o|/]
| | |
1 2 3
NIL
I think that this library could be modified to use reader labels for drawing conses with shared structure if *print-circle* is set to true. For example:
CL-USER> (draw-cons-tree:draw-tree '(#1=(1 2 3) #1#))
[o|o]---[o|/]
| |
| #1#
|
#1=[o|o]---[o|o]---[o|/]
| | |
1 2 3
NIL
Or, alternatively, whichever is easier:
CL-USER> (draw-cons-tree:draw-tree '(#1=(1 2 3) #1#))
[o|o]---[o|/]
| |
#1# #1=[o|o]---[o|o]---[o|/]
| | |
1 2 3
NIL
This also means that the library fails at drawing cyclic structures, such as #1=(#1#). I imagine it could be handled like this:
#1=[o|/]
|
#1#
Would you accept a PR that implements this?