Lisp optimizations
Apr. 10th, 2006 08:02 amgiven a, fn, l, test
Consider:
If
Are there Lisp code optimizers that work by doing this kind of code rewriting?
Consider:
1: (member a (mapcar fn l) :test test)
2: (exists #'(lambda (x) (test a (funcall fn x))) l)
If
fn
is purely-functional code (i.e. no side-effects), then these two are the same, since they evaluate to the same thing. The former is easier to write, but the latter is more efficient. A declarative language should allow you to express things the former way, and yet compute it efficiently.Are there Lisp code optimizers that work by doing this kind of code rewriting?