3 ms·
a + 4*(x-y) + b**5 vs (+ a (* 4 (- x y )) (expt b 5 )) Sometimes, as arithmetic with lisp shows, conciseness is better. Also, it isn't being more explicit
by noobermin 10y ago
a + 4*(x-y) + b**5
vs
(+ a (* 4 (- x y )) (expt b 5 ))
Sometimes, as arithmetic with lisp shows, conciseness is better. Also, it isn't being more explicit than it is being more verbose.
- kazinator 10y agoIt is abosolutely being more explicit. It's being more explicit that (expt b 5) is a unit that forms a single argument in the + form. This is implicit in a + b ** 5 according to a precedence rule between the and + operator, which is hidden in the parser's implementation and in documentation thereof. Well, the white-spacing a + b**5 suggests it. But the suggestions produced by insignificant whitespace can be mere wishful thinking: int* x, y; // two C pointers? not! Speaking of whitespace, also have the advantage of there being multiple ways to split the expression into multiple lines, all conforming to a very clear, simple formatting rule: (+ a (* 4 (- x y)) (expt b 5)) (+ a (* 4 (- x y)) (expt b 5)) Fully expanded, every term on separate line: (+ a (* 4 (- x y)) (expt b 5)) In this manner, we can write complex expressions that would be quite unreadable in infix, requiring break-up into intermediate temporaries. We almost have a circuit diagram now with "gates" for the operations: a three input + gate, etc: ____ / |- a | | ____ --| + |-----/ |- 4 | | | * | ____ \____|- | |-----/ |- x ` \____| | - | | \____|- y | _____ `--/ |- b | expt| \_____|- 5