A Lisp parser for drawing tree diagrams in GLE

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:

to-gle-1

The names of the cells can be wider than just one letter:


(list-to-gle '(aa (bbb (cccc (dddddddd)))))

to-gle-2

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))))

(Click on the picture to enlarge)
to-gle-3

This list has many levels:


(list-to-gle '(a ((b ((c ((d ((e f))))))))))

to-gle-4

The default file name for the output is list.gle

You can choose another name specifying the optional keyword parameter :filename in the list-to-gle function


(list-to-gle '(a b) :filename "another-file.gle")
Advertisements
Published in: on 19/04/2014 at 10:40  Leave a Comment  
Tags:

The URI to TrackBack this entry is: https://burubaxair.wordpress.com/2014/04/19/a-lisp-parser-for-drawing-tree-diagrams-in-gle/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: