LispTree: Draw Maxima objects as trees (using Lisp)My main page on Maxima is here.
1. A problemRun this in Maxima:
The output of the fundef will be:
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 solutionLispTree can display the result of the fundef above in several tree-like formats. Here are some of them:
The last one is called a "Lispy tree". 3. Trying itThe code of LispTree is composed of these three files,
plus edrxbox.lisp, copied from Edrxbox. 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:
You will get something like this screenshot: The demo above was taken from here:
4. The innardsThe 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
See here. 5. Tests in commentsLispTree 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. CFFIIn sep/2025 I added to Lisptree a hack to call Lua. See:
7. EtcLispTree supersedes LuaTree. Lisptree was my first excuse for trying to understand the display code of Maxima, and for writing many, many, many versions of verbatimbox, that ultimately became this example in Edrxbox. See the screenshot below, that I included in this message to the mailing list: More soon! |