Quick
index
main
eev
eepitch
maths
angg
blogme
dednat6
littlelangs
PURO
(C2,C3,C4,
 λ,ES,
 GA,MD,
 Caepro,
 textos,
 Chapa 1)

emacs
lua
(la)tex
maxima
 qdraw
git
lean4
agda
forth
squeak
icon
tcl
tikz
fvwm
debian
irc
contact

LispTree: Draw Maxima objects as trees (using Lisp)

My main page on Maxima is here.
LispTree supersedes LuaTree.

1. A problem
2. A solution
3. Trying it
4. The innards
5. Tests in comments
6. Etc


9:59 Robin
There is no volitional subject
59:57 by putting us on an even playing field,
1:00:01 instead of saying 'normal'.


1. A problem

Run this in Maxima:

format([args]) := apply(?format, append([false], args));
fundef(format);

The output of the fundef will be:

format([args]) := apply(format, append([false], args))

The "?", that indicates that the second "format" is a Lisp symbol, disappeared! We can make it appear by setting lispdisp, but that's not obvious...


2. A solution

LispTree can display the result of the fundef above in several tree-like formats. Here are some of them:

:=______.
|       |
format  apply____.
|       |        |
[       ?format  append__.
|                |       |
args             [       args
                 |       
                 false   
":="_____.
|        |
$FORMAT  $APPLY__.
|        |       |
"["      FORMAT  $APPEND__.
|                |        |
$ARGS            "["      $ARGS
                 |        
                 NIL      
(":=" ($FORMAT ("[" $ARGS)) ($APPLY FORMAT ($APPEND ("[" NIL) $ARGS)))

The last one is called a "Lispy tree".


3. Trying it

The code of LispTree is composed of three files:

Here's one way to try it. Run this - you can ignore the lines with the red stars if you don't use eev/eepitch:

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
rm -Rfv /tmp/lisptree/
cd      /tmp/
git clone https://github.com/edrx/lisptree
cd      /tmp/lisptree/


* (eepitch-maxima)
* (eepitch-kill)
* (eepitch-maxima)
** (find-anchor "/tmp/lisptree/lisptree.mac")
load           ("/tmp/lisptree/lisptree.mac");

         fundef(format);
lisptree(fundef(format));
lisptree0_config(q,s1)$
lisptree(fundef(format));

lisptree (2+3);
lisptreeq(2+3);

You will get something like this screenshot:

The demo above was taken from here:

(find-es "maxima" "lisptree-demo1")


4. The innards

The last line of the demo above was a "lisptreeq(2+3)" that "quoted" its argument instead of simplifying it. That was only possible because the lisptreeq is a macro, and it ran a block with "simp:false". This is a trick that took me a long time to get right, and LispTree is full of other tricks like that. I prefer to think that LispTree is

...like a toy that is slightly interesting if you play with it for a few seconds, and much more interesting if you open it and take its pieces apart to see how everything works.

See here.


5. Tests in comments

LispTree is full of tests in comments. Some of them, but not all, are test blocks.

See show-conses.el and this e-mail about it.


6. Etc

LispTree supersedes LuaTree.

More soon!