7 ms·
(+ 1 2 3) = add 1 and 2 and 3 The syntax is a bit terse but if you teach people a good way to read it it becomes much more readable than 1+2+3 The only reas
by krunaldo 15y ago
(+ 1 2 3) =
add 1 and 2 and 3
The syntax is a bit terse but if you teach people a good way to read it it becomes much more readable than
1+2+3
The only reason we prefer that way is that we are thought that syntax when we do math in school, I have found it much easier to teach people lisp who have no or very little formal education in math.
- Volpe 15y agoWeak arguement. So rather than form a language around our existing learnings (in Math as you say). We should change all our existing learnings to suit a particular language... then it's more readable... riiiiight, good luck with that. :)
- Confusion 15y agoThis argument is based on too shallow an analysis and doesn't stand up to closer examination. (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) Yeah, so it divides (the addition of (-b and the (sqrt of (the difference between (the product of b and b) and (the product of 4, a and c))) by (the multiplication of 2 and a)) Right, that's much easier than (-b + sqrt(b*b - 4*a*c)) / (2*a) (-b plus the sqrt of ((b times b) - (4 times a times c))) divided by (2 times a)
- JBiserkov 15y agoNew lines in the Lisp, PLEASE :) I see you omitted some parenthesis in the "conventional" expression, relying on the fact that multiplication takes priority over substraction. Making this fact explicit is exactly what makes Lisp better, especially for more complex domains: delegating priorities to the notation, freeing brain capacity for the actual problem.
- lispm 15y agoIf math is a problem for the user, there is the option to use a modified parser. For example using an infix parser called by a readmacro: (defun foo (a b c) #I( (-b + sqrt(b*b - 4*a*c)) / (2*a) )) CL-USER 8 > (foo 1 2 3) #C(-1.0 1.4142135)
- Confusion 15y agoSure, there are solutions and it's awesome that they're both possible and easy to use. I'm not arguing against Lisp; I just don't agree that its syntax is better. I agree it is not worse, if you survey a sufficiently large variety of cases. It may be bikeshedding, but I would not let 'blue is better than red, because the sky is blue' pass either.
- wicket232 15y agoOnce you add indentation, and know the simple rule that args line up vertically (unless they're so short that you'd rather leave them), the following is pretty easy to read: (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) It tells me: * there's a quotient of 2 things * the first thing is a sum of -b and a sqrt * the second thing is a product and so on. Pretty nice. Of course, mathematical notation is more terse.