4 ms·
I'm glad you will be doing something more interesting for the second half. I understand that the sqrt function is done for teaching purposes, but there is no p
by anonjon 17y ago
I'm glad you will be doing something more interesting for the second half.
I understand that the sqrt function is done for teaching purposes, but there is no point in showing people how to write an abs function, all it does is give the impression that Clojure doesn't have an absolute value function.
It would be a better use of time to take the opportunity to show people how to import a function from an external library (like clojure.contrib), than it would be to re-implement a relatively mundane function. Using libraries is important and something that should be covered in an introduction to a language.
My point about operator precedence is that it is clearer because it is explicit. When you add exponentiation into infix math notation, it gets very easy to screw stuff up by missing a paren.
xx+yy is ambiguous with x(x+y)y, in lisp it would be (+ (* x x) (* y y)) vs. (* x y (+ x y)).
(The point being that they have vastly different structure).
(Is it ironic that I'm arguing that missing a paren is more annoying in infix than it is in prefix?)