3 ms·
Well, the easiest way to write 1 + x * 2 - 3 % x would just be "x-2". But if we're talking more generally, if I have an expression like 2*x^3 + x^2 - 5*
by Tainnor 3y ago
Well, the easiest way to write
1 + x * 2 - 3 % x
would just be "x-2".
But if we're talking more generally, if I have an expression like
2*x^3 + x^2 - 5*x
a trained eye immediately can read off the coefficients of the polynomial and I'm not sure if that's true of
(+ (* 2 (^ x 3)) (^ x 2) (- (* 5 x)))
- zelphirkalt 3y agoFor writing a program, the s-expression form might become: (+ (* 2 (^ x 3)) (^ x 2) (- (* 5 x))) Whereas: 2*x^3 + x^2 - 5*x Would probably error out in most languages, due to parsing issues and ambiguity. Even worse ambiguity, if you put the signs in front, as then every line could be an expression by itself: 2*x^3 + x^2 - 5*x Could be 3 expressions or 2 or 1.
- Tainnor 3y agoIt might do the wrong thing in some languages but wouldn't necessarily raise a compiler error, and I'm fairly certain e.g. sympy should have no issue with it.