|Lisp S-expression optimization email@example.com (Opium) (2001-02-15)|
|Re: Lisp S-expression optimization firstname.lastname@example.org (2001-02-17)|
|Date:||15 Feb 2001 00:32:01 -0500|
|Keywords:||Lisp, optimize, question|
|Posted-Date:||15 Feb 2001 00:32:01 EST|
The question is how to optimize a lisp s-expression in the parse -
tree phase. I'm playing around with a C++ program that randomly
generates lisp s-expressions: basically I tell it what functions I
want, give it pointers to function declarations and the number of
arguments each function has and then it randomly creates a parse tree
with the functions chosen at random and with variable names (also
chosen randomly) as leaf nodes.
The problem is that most of the time the s-expression is not in its
simplest form eg. if I had the AND and OR functions, a simple ((a AND
b) or c) could wind up as something horendously long (but after some
mathematical simplification would end up as previously stated).
The situation gets a little more complex when you have branching
functions (like the if..then..else) since the if-then-else construct
is just another function with 3 parameters.
So the question becomes, how do I (for a given set of functions)
process the s-expressions generated so that they are all in their
I've been wracking my head for a while on this one.
Any help appreciated
Return to the
Search the comp.compilers archives again.