| 1. If 'a' is a number, (a x b c d ...) == (x a (b c d ...))
So, e.g., (1 + 2 - 3 * 4) == (+ 1 (- 2 (* 3 4)))
This can be implemented in Arc as follows: (defcall int (n . args)
(if no.args
n
(car.args n (apply cadr.args cddr.args))))
(Similarly for 'num.)In effect, this makes all arithmetic operators right-associative with the same precedence. It may not be consistent with convention, but it makes code readable and that's all I really care about. You'd just have to get used to things being a little different from math. 2. Repurpose the pipe character so that, instead of allowing symbols to contain more characters, it forbids all characters except letters and numbers, and places the result in parentheses. So, e.g. |a+b-c| == (a + b - c)
For a complete example, let's take the quadratic formula: (-b + sqrt(b^2 - 4ac)) / 2a
In Lisp, this is (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a))
Applying (1), we get (((- b) + sqrt ((b * b) - 4 * a * c)) / 2 * a)
Applying (2), we get ((|-b| + sqrt (|b*b|-|4*a*c|)) / |2*a|)
Better, no? |