Infpre - A Common Lisp infix utility

Infpre is a prefix <-> infix conversion tool for Common Lisp. The intended use is for CL programs with long math formulas.
The package infpre contains:

How does the infix->prefix function work?

infix->prefix takes two list arguments: the expression and the operators. The expression is just an ordinary lisp list and the operators are math symbols like + and *, where list order gives presedence. An important point is that the operators are not binary, but list separators (like comma), i.e. 1 + 2 + ... is a + separated list.
Example:
 
% (infix->prefix '(1 + 2 * 3 + 4) '(+ *))
(+ 1 (* 2 3) 4)

How does the prefix->infix function work?

Hopefully as expected.

How does the math macro work?

Works as defun, but with infix math. If name is _ then it works as lambda.
Example:
% (math f (x) 
    (let ((a 0.1))
      (exp (-1 * a * expt x 2))))
F
% (f 2)
0.67032003

How does the !! macro work?

It simply applies infix->prefix with standard math operators. Since there are no read macroes there must be spaces between the operators.
(!! (let ((a 42)) a - 2 * 2 * 10))
2

Back to my lisp page