Package COM.INFORMATIMAGO.COMMON-LISP.PICTURE.CONS-TO-ASCII


This packages draws ASCII art cons cell diagrams.


License:

    AGPL3

    Copyright Pascal J. Bourguignon 2004 - 2012

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.
    If not, see <http://www.gnu.org/licenses/>
(draw-cell pict x y cell)
generic-function
Draws the CELL in the picture PICT, at coordinates X,Y
(draw-list list &key title)
function
DO:         Draws the LIST structure.
TITLE:      An alternative title.
RETURN:     A string containing the drawing.
EXAMPLE:    (draw-list '(if (< a b) (decf b a) (decf a b)))
            returns:
           "+-----------------------------------------------------------------------+
            | (if (< a b) (decf b a) (decf a b))                                    |
            |                                                                       |
            | +---+---+   +---+---+   +---+---+   +---+---+                         |
            | | * | * |-->| * | * |-->| * | * |-->| * |NIL|                         |
            | +---+---+   +---+---+   +---+---+   +---+---+                         |
            |   |           |           |           |                               |
            |   v           |           |           v                               |
            | +----+        |           |         +---+---+   +---+---+   +---+---+ |
            | | if |        |           |         | * | * |-->| * | * |-->| * |NIL| |
            | +----+        |           |         +---+---+   +---+---+   +---+---+ |
            |               |           |           |           |           |       |
            |               |           |           v           v           v       |
            |               |           |         +------+    +---+       +---+     |
            |               |           |         | decf |    | a |       | b |     |
            |               |           |         +------+    +---+       +---+     |
            |               |           v                                           |
            |               |         +---+---+   +---+---+   +---+---+             |
            |               |         | * | * |-->| * | * |-->| * |NIL|             |
            |               |         +---+---+   +---+---+   +---+---+             |
            |               |           |           |           |                   |
            |               |           v           v           v                   |
            |               |         +------+    +---+       +---+                 |
            |               |         | decf |    | b |       | a |                 |
            |               |         +------+    +---+       +---+                 |
            |               v                                                       |
            |             +---+---+   +---+---+   +---+---+                         |
            |             | * | * |-->| * | * |-->| * |NIL|                         |
            |             +---+---+   +---+---+   +---+---+                         |
            |               |           |           |                               |
            |               v           v           v                               |
            |             +---+       +---+       +---+                             |
            |             | < |       | a |       | b |                             |
            |             +---+       +---+       +---+                             |
            +-----------------------------------------------------------------------+"
(print-conses tree &optional stream)
function
DO:         Print the TREE with all cons cells as dotted pairs.
TREE:       A sexp.
STREAM:     The output stream (default: *STANDARD-OUTPUT*)
WARNING:    doesn't handle circles nor identify EQ subtrees.
EXAMPLE:    (print-conses '(a b c d))
            prints:
            (a  . (b  . (c  . (d  . ()))))
(print-identified-conses tree &optional stream)
function
DO:      Print the TREE with all cons cells identified with a #n= notation.
TREE:    A sexp.
STREAM:  The output stream (default: *STANDARD-OUTPUT*)
NOTE:    Handles circles in the cons structure, but not thru the other
         atoms (vectors, structures, objects).
EXAMPLE: (print-identified-conses '((a . b) #1=(c . d) (e . #1#)))
         prints:
         ((a . b) . (#1=(c . d) . ((e . #1# ) . ())))