I have written a Common Lisp library for building trees which I'm making available under a "do anything you want license". It can be downloaded
at http://vlaho.ninja/prog/#trbu .For a more detailed explanation here
is an excerpt from
http://vlaho.ninja/prog/trbu/README.txt
{
When writing code for macros , the macro code generally constructs a list which is the macro expansion. Sometimes you can do this using MAPCAR and similar. But often I found myself in a situation where I constructed a partial list and then , as I was parsing the code given in an invocation
of the macro , I gradually wanted to add more elements to the end of the list. Using the standard APPEND for this gives quadratic performance. So
what I was doing was to PUSH elements to the front of the list and , when
I had created the whole expansion , I would do (reverse list) .With this approach the code I was writing often looked unnatural to me. In
situations where one can construct the expansion list in one loop and it's not convenient to use MAPCAR {or similar} , many people would use LOOP .I don't like LOOP either so I needed a different solution hence I wrote this library. The main idea is that you can append to the list you are constructing in constant time rather than having to traverse the whole
list from the start. It's not just for macro expansions obviously but I almost exclusively use it for that because , in every other situation where
I need a sequence , I'm much more likely to use a vector than a list.
}
http://vlaho.ninja/prog/trbu/manual.txt has plenty of examples.
I have written a Common Lisp library for building trees
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 298 |
Nodes: | 16 (2 / 14) |
Uptime: | 23:55:46 |
Calls: | 6,678 |
Calls today: | 1 |
Files: | 12,222 |
Messages: | 5,341,916 |
Posted today: | 1 |