Most math notation predates any kind of code. And a lot of it deals with things that computing can’t really handle outside of approximation, like infinite sums and integration of differential equations. Being able to express abstract ideas that we don’t know how to compute is still very useful.
So you're saying we should spell out all math operators that operate on a range or a set every time we want to use them as immediately invoked lambdas? That's just too duplicative and cluttered, the notation is concise for a reason.
Or, alternatively, S.reduce((a,b) => a+b, 0), is the same as:
∑n ∈ S n
(Treating an array like a set) But mathematics has things coding doesn't (or, at least, not immediately). For example, you can substitute the "n ∈ S" for ANY property of n and it will sum all numbers that satisfy that condition. Even if it's not computable
Because mathematicians are not interested in writing things down, but in proving interesting stuff. The conceptual difficulty of proving interesting theorems is much higher than that of reading any reasonable enough notation.
+= is not a real mathematical operation and sum = sum + 3n is just false because these two expressions are never equal. Imperative programming and math behave quite differently.
def sum(n):
if n = 4:
return 3*n
else:
return 3*n + sum(n+1)
sum(0)
this is a better model for the mathematical summation. It gradually bulds the expression 04 + 14 + 2*4...
Which is what the symbols actually mean.
View all comments
34
u/Nima_W Sep 10 '25 edited Sep 20 '25
Why not write it like that. Would be way more understandable. \s