Related articles |
---|
Lisp S-expression optimization numenaur@yahoo.com (Opium) (2001-02-15) |
Re: Lisp S-expression optimization stephan@pcrm.win.tue.nl (2001-02-17) |
From: | stephan@pcrm.win.tue.nl () |
Newsgroups: | comp.compilers |
Date: | 17 Feb 2001 01:33:10 -0500 |
Organization: | Eindhoven University of Technology, The Netherlands |
References: | 01-02-060 |
Keywords: | Lisp, optimize |
Posted-Date: | 17 Feb 2001 01:33:10 EST |
On 15 Feb 2001 00:32:01 -0500, Opium <numenaur@yahoo.com> wrote:
>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
>simplest form?
Depending on the constructs you have in your parse tree, this problem
might not be computable. So finding the simplest form might not be possible,
and you might have to stick with just finding a simpler form.
A simple optimisation is to evaluate everything you can. I.e.
(+ 1 2) ==> 3. Also note rules of the form: (#f is false, #t is true)
(and #f x) ==> #f
(and #t x) ==> x
(or #f x) ==> x
(or #t x) ==> #t
(and x x) ==> x
(or x x) ==> x
(if x y y) ==> y
Etcetera.
Good luck,
Stephan
--
ir. Stephan H.M.J. Houben
tel. +31-40-2474358 / +31-40-2743497
e-mail: stephanh@win.tue.nl
Return to the
comp.compilers page.
Search the
comp.compilers archives again.