Recently, I gave my student, Alexandr Nigay, an exercise to write a Lisp parser that given a list creates a GLE file for drawing a tree diagram corresponding to that list.
He wrote it and sent his code to me.
I made some corrections and added a few things to the program.
He then implemented some more of his ideas that improved it.
I present our final version here.
I like such iterative teacher-student code development.
It is much more enjoyable than traditional way of giving assignments and then grading them.
I hope Alexandr also enjoyed working on the code. He is an excellent student.
I will probably work on such small projects with students from time to time and post the results in this blog.
Anyone is welcome to participate — you don’t have to attend my class for that. Just send me an e-mail, even if you are on another side of the Earth.
The code is here: to-gle.lisp
If you type in REPL the command
(list-to-gle '(a b (c d)))
the program will create the following GLE file:
The names of the cells can be wider than just one letter:
(list-to-gle '(aa (bbb (cccc (dddddddd)))))
The program also calculates the size of the picture depending on how big your list is.
This is a long list:
(list-to-gle '(w (x . (y . v)) (g h i ((w . (a . (b . c))) . k)) ((d) (e) (f (d (k l (m n))))) ((a) (b) (c))))
This list has many levels:
(list-to-gle '(a ((b ((c ((d ((e f))))))))))
The default file name for the output is
You can choose another name specifying the optional keyword parameter
:filename in the
(list-to-gle '(a b) :filename "another-file.gle")